Im using jetty websocket. Do I need to call stop() here, because its already closing:…
- User
Im using jetty websocket. Do I need to call stop() here, because its already closing: @Override public void onWebSocketClose(int statusCode, String reason) { System.out.println("WebSocket closed");
codeif(!client.isStopped() && !client.isStopping()) { try { client.stop(); } catch(Throwable e) { e.printStackTrace(); } } if(statusCode == 4009) { runEventCallback(onDisconnected, "Password incorrect. Check Tools -> WebSockets Server Settings.\n" + statusCode + " - " + reason); } else { runEventCallback(onDisconnected, "Disconnected from OBS WebSocket: " + statusCode + " - " + reason); } } - Assistant
Based on the code provided, it seems like you should not call
stop()inside theonWebSocketClosemethod.The
onWebSocketClosemethod is called when the WebSocket connection is closed. In your code, you check if the client is not stopped and not stopping before callingstop(). This suggests that theclientis a reference to the WebSocket client that you are using.Calling
stop()on the client object here may not be necessary because the WebSocket connection is already closing. It is important to note that callingstop()on the client object will stop the client and it may not be possible to start it again.If you want to ensure that the client is stopped when the WebSocket connection is closed, you can call
stop()before closing the connection.