mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-19 09:08:05 +01:00
Don't retry "connection closed" errors
This commit is contained in:
committed by
Jon Chambers
parent
5cb3a053fb
commit
a4804f6501
@@ -388,7 +388,7 @@ public class WebSocketConnection implements MessageAvailabilityListener, Disconn
|
||||
Mono.fromFuture(() -> sendMessage(envelope)).timeout(sendFuturesTimeout)
|
||||
// Note that this will retry both for "send to client" timeouts and failures to delete messages on
|
||||
// acknowledgement
|
||||
.retryWhen(Retry.backoff(4, Duration.ofSeconds(1))),
|
||||
.retryWhen(Retry.backoff(4, Duration.ofSeconds(1)).filter(throwable -> !isConnectionClosedException(throwable))),
|
||||
MESSAGE_SENDER_MAX_CONCURRENCY)
|
||||
.doOnError(this::measureSendMessageErrors)
|
||||
.subscribeOn(messageDeliveryScheduler)
|
||||
@@ -410,10 +410,7 @@ public class WebSocketConnection implements MessageAvailabilityListener, Disconn
|
||||
|
||||
if (e instanceof TimeoutException) {
|
||||
errorType = "timeout";
|
||||
} else if (e instanceof java.nio.channels.ClosedChannelException ||
|
||||
e == WebSocketResourceProvider.CONNECTION_CLOSED_EXCEPTION ||
|
||||
e instanceof org.eclipse.jetty.io.EofException ||
|
||||
(e instanceof StaticException staticException && "Closed".equals(staticException.getMessage()))) {
|
||||
} else if (isConnectionClosedException(e)) {
|
||||
errorType = "connectionClosed";
|
||||
} else {
|
||||
logger.warn("Send message failed", e);
|
||||
@@ -427,6 +424,13 @@ public class WebSocketConnection implements MessageAvailabilityListener, Disconn
|
||||
.increment();
|
||||
}
|
||||
|
||||
private static boolean isConnectionClosedException(final Throwable throwable) {
|
||||
return throwable instanceof java.nio.channels.ClosedChannelException ||
|
||||
throwable == WebSocketResourceProvider.CONNECTION_CLOSED_EXCEPTION ||
|
||||
throwable instanceof org.eclipse.jetty.io.EofException ||
|
||||
(throwable instanceof StaticException staticException && "Closed".equals(staticException.getMessage()));
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> sendMessage(Envelope envelope) {
|
||||
final UUID messageGuid = UUID.fromString(envelope.getServerGuid());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user