Skip to content

Commit 78f5760

Browse files
authored
Set a more sane timeout for WS connections and log WS errors (#1992)
1 parent d341ebb commit 78f5760

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

photon-server/src/main/java/org/photonvision/server/DataSocketHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ private DataSocketHandler() {
6969

7070
public void onConnect(WsConnectContext context) {
7171
users.add(context);
72-
context.session.setIdleTimeout(
73-
Duration.ofMillis(Long.MAX_VALUE)); // TODO: determine better value
72+
context.session.setIdleTimeout(Duration.ofMillis(5000));
7473
var remote = (InetSocketAddress) context.session.getRemoteAddress();
7574
var host = remote.getAddress().toString() + ":" + remote.getPort();
7675
logger.info("New websocket connection from " + host);

photon-server/src/main/java/org/photonvision/server/Server.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ private static void start(int port) {
109109
ws -> {
110110
ws.onConnect(dsHandler::onConnect);
111111
ws.onClose(dsHandler::onClose);
112+
ws.onError(e -> logger.error(e.toString(), e.error()));
112113
ws.onBinaryMessage(dsHandler::onBinaryMessage);
113114
});
114115

0 commit comments

Comments
 (0)