diff --git a/src/dorkbox/network/Client.kt b/src/dorkbox/network/Client.kt index 9c53e6ba..1fe24b8c 100644 --- a/src/dorkbox/network/Client.kt +++ b/src/dorkbox/network/Client.kt @@ -228,6 +228,9 @@ open class Client(config: Configuration = Configuration ipcPublicationId: Int = AeronConfig.IPC_HANDSHAKE_STREAM_ID_SUB, ipcSubscriptionId: Int = AeronConfig.IPC_HANDSHAKE_STREAM_ID_PUB, connectionTimeoutMS: Long = 30_000L, reliable: Boolean = true) { + + require(connectionTimeoutMS >= 0) { "connectionTimeoutMS '$connectionTimeoutMS' is invalid. It must be >0" } + // this will exist ONLY if we are reconnecting via a "disconnect" callback lockStepForReconnect.value?.doWait() diff --git a/src/dorkbox/network/handshake/ClientHandshake.kt b/src/dorkbox/network/handshake/ClientHandshake.kt index 243c89be..2555b559 100644 --- a/src/dorkbox/network/handshake/ClientHandshake.kt +++ b/src/dorkbox/network/handshake/ClientHandshake.kt @@ -138,7 +138,7 @@ internal class ClientHandshake(private val crypto: Crypt val pollIdleStrategy = endPoint.config.pollIdleStrategy val startTime = System.currentTimeMillis() - while (System.currentTimeMillis() - startTime < connectionTimeoutMS) { + while (connectionTimeoutMS == 0L || System.currentTimeMillis() - startTime < connectionTimeoutMS) { // NOTE: regarding fragment limit size. Repeated calls to '.poll' will reassemble a fragment. // `.poll(handler, 4)` == `.poll(handler, 2)` + `.poll(handler, 2)` pollCount = subscription.poll(handler, 1) @@ -183,7 +183,7 @@ internal class ClientHandshake(private val crypto: Crypt val pollIdleStrategy = endPoint.config.pollIdleStrategy var startTime = System.currentTimeMillis() - while (System.currentTimeMillis() - startTime < connectionTimeoutMS) { + while (connectionTimeoutMS == 0L || System.currentTimeMillis() - startTime < connectionTimeoutMS) { // NOTE: regarding fragment limit size. Repeated calls to '.poll' will reassemble a fragment. // `.poll(handler, 4)` == `.poll(handler, 2)` + `.poll(handler, 2)` pollCount = subscription.poll(handler, 1)