TooTallNate / Java-WebSocket

A barebones WebSocket client and server implementation written in 100% Java.
http://tootallnate.github.io/Java-WebSocket
MIT License
10.53k stars 2.58k forks source link

WebSocketClient.closeBlocking() will wait for 7 minutes on service #1317

Closed hytTony closed 4 months ago

hytTony commented 1 year ago

I used closeBlocking() to close the websocket, it works correct on activity. Now i move these code to back service, then it will block about 7 minutes on closeBlocking().

Sure, i can close it without bolcking, such as close(), or close it in another thread. But it just release the thread, the websocket still be blocked, it cann't be used before it closed ( It will not work even new another websocket).

my code like this: clientSocket = new JWebSocketClient(uri, httpHeaders){...}; clientSocket.setConnectionLostTimeout(220); clientSocket.connectBlocking(2, TimeUnit.MINUTES);

and close it like this: clientSocket.closeBlocking();

What is the problem, if there are solve solution?