We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f7d51a8 commit d8eb0f8Copy full SHA for d8eb0f8
1 file changed
src/main/java/org/java_websocket/client/WebSocketClient.java
@@ -339,7 +339,9 @@ private void reset() {
339
"You cannot initialize a reconnect out of the websocket thread. Use reconnect in another thread to ensure a successful cleanup.");
340
}
341
try {
342
- if (engine.getReadyState() == ReadyState.NOT_YET_CONNECTED) {
+ // 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
345
socket.close();
346
347
closeBlocking();
0 commit comments