From 2dc26cf7bf2868c05df45f266182a9cae15e1649 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sat, 28 Jul 2018 22:19:16 +0100 Subject: [PATCH] do not log warning on SocketTimeoutExceptions --- core/src/main/groovy/com/muwire/core/Core.groovy | 3 +++ .../main/groovy/com/muwire/core/connection/Connection.groovy | 2 ++ 2 files changed, 5 insertions(+) diff --git a/core/src/main/groovy/com/muwire/core/Core.groovy b/core/src/main/groovy/com/muwire/core/Core.groovy index 7e278ba4..8daf3e56 100644 --- a/core/src/main/groovy/com/muwire/core/Core.groovy +++ b/core/src/main/groovy/com/muwire/core/Core.groovy @@ -20,6 +20,7 @@ import net.i2p.client.I2PClientFactory import net.i2p.client.I2PSession import net.i2p.client.streaming.I2PSocketManager import net.i2p.client.streaming.I2PSocketManagerFactory +import net.i2p.client.streaming.I2PSocketOptions @Log class Core { @@ -63,6 +64,8 @@ class Core { keyDat.withInputStream { socketManager = new I2PSocketManagerFactory().createManager(it, sysProps) } + socketManager.getDefaultOptions().setReadTimeout(60000) + socketManager.getDefaultOptions().setConnectTimeout(30000) i2pSession = socketManager.getSession() diff --git a/core/src/main/groovy/com/muwire/core/connection/Connection.groovy b/core/src/main/groovy/com/muwire/core/connection/Connection.groovy index e4c00c9a..e3dad356 100644 --- a/core/src/main/groovy/com/muwire/core/connection/Connection.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/Connection.groovy @@ -73,6 +73,8 @@ abstract class Connection implements Closeable { while(running.get()) { read() } + } catch (SocketTimeoutException e) { + close() } catch (Exception e) { if (running.get()) { log.log(Level.WARNING,"unhandled exception in reader",e)