File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
src/main/java/org/java_websocket/client Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -339,7 +339,9 @@ private void reset() {
339339 "You cannot initialize a reconnect out of the websocket thread. Use reconnect in another thread to ensure a successful cleanup." );
340340 }
341341 try {
342- if (engine .getReadyState () == ReadyState .NOT_YET_CONNECTED ) {
342+ // This socket null check ensures we can reconnect a socket that failed to connect. It's an uncommon edge case, but we want to make sure we support it
343+ if (engine .getReadyState () == ReadyState .NOT_YET_CONNECTED && socket != null ) {
344+ // Closing the socket when we have not connected prevents the writeThread from hanging on a write indefinitely during connection teardown
343345 socket .close ();
344346 }
345347 closeBlocking ();
You can’t perform that action at this time.
0 commit comments