From 2ad703c5f85e6df3d5ba764389d5db47d90d9d22 Mon Sep 17 00:00:00 2001 From: Wessel Date: Mon, 8 Dec 2025 21:26:54 +0100 Subject: [PATCH] Set socket timeout to 5s (#3929) Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com> Co-authored-by: James Rich <2199651+jamesarich@users.noreply.github.com> --- .../com/geeksville/mesh/repository/radio/TCPInterface.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/repository/radio/TCPInterface.kt b/app/src/main/java/com/geeksville/mesh/repository/radio/TCPInterface.kt index 66d91cf43..4bb6d8ff7 100644 --- a/app/src/main/java/com/geeksville/mesh/repository/radio/TCPInterface.kt +++ b/app/src/main/java/com/geeksville/mesh/repository/radio/TCPInterface.kt @@ -41,6 +41,8 @@ class TCPInterface @AssistedInject constructor(service: RadioInterfaceService, @ const val MAX_RETRIES_ALLOWED = Int.MAX_VALUE const val MIN_BACKOFF_MILLIS = 1 * 1000L // 1 second const val MAX_BACKOFF_MILLIS = 5 * 60 * 1000L // 5 minutes + const val SOCKET_TIMEOUT = 5000 + const val SOCKET_RETRIES = 18 const val SERVICE_PORT = NetworkRepository.SERVICE_PORT } @@ -106,7 +108,7 @@ class TCPInterface @AssistedInject constructor(service: RadioInterfaceService, @ Socket(InetAddress.getByName(host), port).use { socket -> socket.tcpNoDelay = true - socket.soTimeout = 500 + socket.soTimeout = SOCKET_TIMEOUT this@TCPInterface.socket = socket BufferedOutputStream(socket.getOutputStream()).use { outputStream -> @@ -119,7 +121,7 @@ class TCPInterface @AssistedInject constructor(service: RadioInterfaceService, @ backoffDelay = MIN_BACKOFF_MILLIS var timeoutCount = 0 - while (timeoutCount < 180) { + while (timeoutCount < SOCKET_RETRIES) { try { // close after 90s of inactivity val c = inputStream.read() if (c == -1) {