From 4bd77515d839fad3e860d7f744555b443fc1b272 Mon Sep 17 00:00:00 2001 From: Robinson Date: Fri, 3 Nov 2023 18:21:35 +0100 Subject: [PATCH] Increased connection timeouts. --- src/dorkbox/network/Client.kt | 2 +- src/dorkbox/network/Configuration.kt | 4 ++-- src/dorkbox/network/handshake/ServerHandshake.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dorkbox/network/Client.kt b/src/dorkbox/network/Client.kt index ed9592ca..fa0eff89 100644 --- a/src/dorkbox/network/Client.kt +++ b/src/dorkbox/network/Client.kt @@ -534,7 +534,7 @@ open class Client(config: ClientConfiguration = ClientC (config.enableIpc && (remoteAddress == null || isSelfMachine)) || (!config.enableIpc && remoteAddress == null) // how long does the initial handshake take to connect - var handshakeTimeoutNs = aeronDriver.publicationConnectionTimeoutNs() + aeronDriver.lingerNs() + var handshakeTimeoutNs = TimeUnit.SECONDS.toNanos(config.connectionCloseTimeoutInSeconds.toLong()) + aeronDriver.publicationConnectionTimeoutNs() + aeronDriver.lingerNs() // how long before we COMPLETELY give up retrying. A '0' means try forever. var connectionTimoutInNs = TimeUnit.SECONDS.toNanos(connectionTimeoutSec.toLong()) diff --git a/src/dorkbox/network/Configuration.kt b/src/dorkbox/network/Configuration.kt index ac95baf9..d8dc6097 100644 --- a/src/dorkbox/network/Configuration.kt +++ b/src/dorkbox/network/Configuration.kt @@ -455,7 +455,7 @@ abstract class Configuration protected constructor() { /** * How long a connection must be disconnected before we cleanup the memory associated with it */ - var connectionCloseTimeoutInSeconds: Int = 10 + var connectionCloseTimeoutInSeconds: Int = 60 set(value) { require(!contextDefined) { errorMessage } field = value @@ -469,7 +469,7 @@ abstract class Configuration protected constructor() { * * Too low and it's likely to get false-positives, too high and there will be some lag when detecting if a connection has been disconnected. */ - var connectionExpirationTimoutNanos = TimeUnit.SECONDS.toNanos(2) + var connectionExpirationTimoutNanos = TimeUnit.SECONDS.toNanos(4) set(value) { require(!contextDefined) { errorMessage } field = value diff --git a/src/dorkbox/network/handshake/ServerHandshake.kt b/src/dorkbox/network/handshake/ServerHandshake.kt index b420ef47..d4e14d39 100644 --- a/src/dorkbox/network/handshake/ServerHandshake.kt +++ b/src/dorkbox/network/handshake/ServerHandshake.kt @@ -74,7 +74,7 @@ internal class ServerHandshake( init { // we MUST include the publication linger timeout, otherwise we might encounter problems that are NOT REALLY problems - var handshakeTimeoutNs = aeronDriver.publicationConnectionTimeoutNs() + aeronDriver.lingerNs() + var handshakeTimeoutNs = TimeUnit.SECONDS.toNanos(config.connectionCloseTimeoutInSeconds.toLong()) + aeronDriver.publicationConnectionTimeoutNs() + aeronDriver.lingerNs() if (EndPoint.DEBUG_CONNECTIONS) { // connections are extremely difficult to diagnose when the connection timeout is short