From d3424143ee459d0867631aa50e45dd3392f0e1a0 Mon Sep 17 00:00:00 2001 From: NuttyShrimp Date: Tue, 23 Apr 2024 21:46:59 +0200 Subject: [PATCH] fix(ws-fetcher): let websocket timeout fail silently --- .../telraam/station/websocket/WebsocketClient.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/telraam/station/websocket/WebsocketClient.java b/src/main/java/telraam/station/websocket/WebsocketClient.java index 260baee..dbab406 100644 --- a/src/main/java/telraam/station/websocket/WebsocketClient.java +++ b/src/main/java/telraam/station/websocket/WebsocketClient.java @@ -1,6 +1,7 @@ package telraam.station.websocket; import jakarta.websocket.*; +import org.eclipse.jetty.websocket.core.exception.WebSocketTimeoutException; import java.net.URI; @@ -27,14 +28,21 @@ public void listen() throws RuntimeException { try { WebSocketContainer container = ContainerProvider.getWebSocketContainer(); container.setDefaultMaxTextMessageBufferSize(100 * 1048576); // 100Mb - container.setDefaultMaxSessionIdleTimeout(0); - container.setAsyncSendTimeout(0); + container.setDefaultMaxSessionIdleTimeout(60); container.connectToServer(this, endpoint); } catch (Exception e) { throw new RuntimeException(e); } } + @OnError + public void onError(Session session, Throwable error) throws Throwable { + if (error instanceof WebSocketTimeoutException) { + return; + } + throw error; + } + @OnOpen public void onOpen(Session session) { this.session = session;