Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket makes two connections #245

Closed
vsranjitroshan opened this issue Apr 8, 2023 · 1 comment
Closed

Websocket makes two connections #245

vsranjitroshan opened this issue Apr 8, 2023 · 1 comment

Comments

@vsranjitroshan
Copy link

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?

@vsranjitroshan
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant