Skip to content

Commit

Permalink
Fix multiple issues related to reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipRoman committed Nov 1, 2023
1 parent bc180ae commit 85b4999
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/org/java_websocket/client/WebSocketClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,12 @@ private void reset() {
closeBlocking();
if (writeThread != null) {
this.writeThread.interrupt();
this.writeThread.join();
this.writeThread = null;
}
if (connectReadThread != null) {
this.connectReadThread.interrupt();
this.connectReadThread.join();
this.connectReadThread = null;
}
this.draft.reset();
Expand Down Expand Up @@ -505,6 +507,14 @@ public void run() {
throw e;
}

if (writeThread != null) {
writeThread.interrupt();
try {
writeThread.join();
} catch (InterruptedException e) {
/* ignore */
}
}
writeThread = new Thread(new WebsocketWriteThread(this));
writeThread.start();

Expand All @@ -523,7 +533,6 @@ public void run() {
onError(e);
engine.closeConnection(CloseFrame.ABNORMAL_CLOSE, e.getMessage());
}
connectReadThread = null;
}

private void upgradeSocketToSSL()
Expand Down Expand Up @@ -801,7 +810,6 @@ public void run() {
handleIOException(e);
} finally {
closeSocket();
writeThread = null;
}
}

Expand Down

0 comments on commit 85b4999

Please sign in to comment.