Repository navigation
Hang on reconnectBlocking #1365
Copy link
Copy link
Closed
Description
Describe the bug
Sometime WebSocketClient hangs on reconnectBlocking() at WebSocketClient.java:422 on closeLatch.await(). That happens very occasionally.
To Reproduce
Steps to reproduce the behavior:
- Setup server and client
- Connect to Server
- call
reconnectBlocking()in a loop
Expected behavior
reconnectBlocking() should never hang
Debug log
The only log:
11:36:42.216 [WebSocketConnectReadThread-5820] TRACE org.java_websocket.WebSocketImpl -- write(171): GET / HTTP/1.1
Connection: Upgrade
Host: localhost:41516
Sec-WebSocket-Key: HGF5XrGAw3IBiWJKCnLPTA==
Sec-WebSocket-Version: 13
Upgrade: websocket
11:36:42.222 [WebSocketConnectReadThread-5820] TRACE org.java_websocket.WebSocketImpl -- process(148): (HTTP/1.1 101 Switching Protocols
Content-Length: 0
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Accept: TfhKZHYT6wDgMrIvABVEeUyEBiw=
)
11:36:42.222 [WebSocketConnectReadThread-5820] TRACE o.java_websocket.drafts.Draft_6455 -- acceptHandshakeAsClient - Matching extension found: DefaultExtension
11:36:42.222 [WebSocketConnectReadThread-5820] TRACE o.java_websocket.drafts.Draft_6455 -- acceptHandshake - Matching protocol found:
11:36:42.222 [WebSocketConnectReadThread-5820] TRACE org.java_websocket.WebSocketImpl -- open using draft: Draft_6455 extension: DefaultExtension protocol: max frame size: 2147483647
11:36:42.222 [WebSocketConnectReadThread-5820] TRACE o.java_websocket.AbstractWebSocket -- Connection lost timer started
"Test worker@1" prio=5 tid=0x1 nid=NA waiting
java.lang.Thread.State: WAITING
at jdk.internal.misc.Unsafe.park(Unsafe.java:-1)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:211)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:715)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1047)
at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:230)
at org.java_websocket.client.WebSocketClient.closeBlocking(WebSocketClient.java:422)
at org.java_websocket.client.WebSocketClient.reset(WebSocketClient.java:343)
at org.java_websocket.client.WebSocketClient.reconnectBlocking(WebSocketClient.java:327)
Environment(please complete the following information):
- Version used: 1.5.4
- Java version: 17
- Operating System and version: Windows 10
Reactions are currently unavailable
Activity
PhilipRoman commentedon Oct 18, 2023
Thanks for the detailed bug reports. I will try to take a look, most likely next week as I'm very busy right now.
nilkanth0018 commentedon Oct 25, 2023
Facing same issue while
connectBlocking()also,What happened in my case:
When I try to connect first time using connectBlocking(), 4 out of 5 times it gives an error on
WebSocketClient.javaclassLine No: 515, it is not specific error and also it will not go into the catch block, it just step out the method.Then I reconnecting using
reconnectBlocking()So in the
reset()method, it stuck atLine No: 343atcloseBlocking(), becausecloseLatchis awaiting atLine No: 422One more thing when we shutdown the server at that time it throw error on client side. Utill it will hang on awaiting state.
I am also using
Version : 1.5.4
Java version: Adoptium OpenJDK 17
Operating System and version: Windows 10
Can you please, Help!
nilkanth0018 commentedon Nov 3, 2023
@PhilipRoman any update on this?
PhilipRoman commentedon Nov 3, 2023
@nilkanth0018
A few days ago I implemented a fix for a closely related issue (see #1367 )
If possible, could you try building the library from branch
reconnect-fixand test if this issue occurs for you? It is simple, just runAnd the jar will appear in target directory
Xander-Polishchuk commentedon Nov 6, 2023
@PhilipRoman Thanks for the fix! I will have a look on this week closer to the end.
Xander-Polishchuk commentedon Nov 29, 2023
@PhilipRoman sorry for delay, tested with the branch and everything seems working a it should be. I don't observe any hangs or NPE. Thanks you for the fix!
Xander-Polishchuk commentedon Dec 11, 2023
Hey @PhilipRoman any chance to have a bugfix release with the fix? Thanks!
PhilipRoman commentedon Dec 16, 2023
@marci4 does the releases