I am creating a websocket connection to a server hosted by QWebSocketServer over my localhost. Whenever I try to connect,
the onConnected function is called twice. Is this only supposed to be called once right? this causes some problems with the server side code, since there are now two clients there.
There was a error on the server side, it drops the connection due to some reason and again the connection is established. This library is working amazingly. Thanks @TakahikoKawasaki
I am creating a websocket connection to a server hosted by QWebSocketServer over my localhost. Whenever I try to connect, the onConnected function is called twice. Is this only supposed to be called once right? this causes some problems with the server side code, since there are now two clients there.
@Override public void onConnected(WebSocket websocket, Map<String, List<String>> headers) throws Exception { websocket.sendText("Hello"); Log.i("WS", "CONNECTED"); }
I am only calling this code once in my android app.
factory = new WebSocketFactory().setConnectionTimeout(500); nvWebSocketListener = new NvWebSocketListener(); try { webSocket = factory.createSocket("ws://192.168.0.25:12345"); webSocket.addListener(nvWebSocketListener); webSocket.connect(); } catch (IOException e) { throw new RuntimeException(e); } catch (WebSocketException e) { throw new RuntimeException(e); }
Can you please guide on what can be done to avoid this issue?