TooTallNate / Java-WebSocket

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

Deadlock on client connect when using multiple client threads and SSLcontext #985

Open bluelu opened 4 years ago

bluelu commented 4 years ago

Hi,

One of the clients will hang forever on creating the connection to the server when multiple threads are used and the SSL Context is used:

park:-1, Unsafe (jdk.internal.misc) park:194, LockSupport (java.util.concurrent.locks) parkAndCheckInterrupt:885, AbstractQueuedSynchronizer (java.util.concurrent.locks) doAcquireSharedInterruptibly:1039, AbstractQueuedSynchronizer (java.util.concurrent.locks) acquireSharedInterruptibly:1345, AbstractQueuedSynchronizer (java.util.concurrent.locks) await:232, CountDownLatch (java.util.concurrent) connectBlocking:367, WebSocketClient (org.java_websocket.client)

There is no issue if:

Please see below (it sets up the sslcontext as described in your example) which will reproduce the problem. (It will output forever waiting for future)

Link to example to recreate issue: https://pastebin.com/hF5kpqyE

bluelu commented 4 years ago

Unfortunately I also managed to get the hanging threads with multiple threads and the synchronize on connectBlocking. It just seems to happen less often, thus probably a race condition somewhere.

BTCPowerDev commented 3 years ago

Hello Everyone,

Is there any planning to resolve this issue in any upcoming releases?