Skip to content

Commit

Permalink
Fix reconnect issues
Browse files Browse the repository at this point in the history
  • Loading branch information
zb-sr committed Jul 1, 2024
1 parent c8171fd commit 1b36cf5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void sendLoop() {
try {
sendMsg(ws, msgs);
} catch (final Exception e) {
this.receiveQueue.add(new ExcWsOutputMessage(msg, new WebSocketConnectionException(e)));
this.receiveQueue.add(new ExcWsOutputMessage(null, new WebSocketConnectionException(e)));
reconnectWebSocket(ws, false);
sendMsg(this.webSocket.get(), msgs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ private <R extends ContentResponse> void enqueueSendMsg(final Awaiter<R> awaiter
releaseAwaiter(awaiter.getCorrelationId());
return;
}
if (awaiter.getFuture().isDone()) {
releaseAwaiter(awaiter.getCorrelationId());
return;
}

sendQueue.add(awaiter.getSendWsInputMessage());

Expand Down Expand Up @@ -253,6 +257,9 @@ private void handleExcWsOutputMessage(final ExcWsOutputMessage msg) {
}

private boolean responseReceived(final String correlationId, final Response response) {
if (correlationId == null) {
return false;
}
final Awaiter<?> awaiter = correlationIdAwaiter.get(correlationId);
if (response.getContent() != null
&& awaiter != null
Expand All @@ -265,6 +272,9 @@ private boolean responseReceived(final String correlationId, final Response resp
}

private boolean responseReceived(final String correlationId, final SdkException sdkException) {
if (correlationId == null) {
return false;
}
final Awaiter<?> awaiter = correlationIdAwaiter.get(correlationId);
if (awaiter != null) {
awaiter.completeWithException(sdkException);
Expand Down

0 comments on commit 1b36cf5

Please sign in to comment.