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)