From 84ca9d7dcf7cc8426001787584db5af53ff27316 Mon Sep 17 00:00:00 2001 From: Igor Artamonov Date: Thu, 23 Sep 2021 22:27:33 -0400 Subject: [PATCH] problem: disconnects from WebSocket if multiple upstreams are set --- .../dshackle/upstream/ethereum/EthereumWsFactory.kt | 6 +++--- .../emeraldpay/dshackle/upstream/ethereum/EthereumWsHead.kt | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsFactory.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsFactory.kt index e2f70168..48324ffc 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsFactory.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsFactory.kt @@ -141,9 +141,8 @@ class EthereumWsFactory( } fun connect() { - if (keepConnection) { - connectInternal() - } + keepConnection = true + connectInternal() } private fun tryReconnectLater() { @@ -383,6 +382,7 @@ class EthereumWsFactory( } override fun close() { + log.info("Closing connection to WebSocket $uri") keepConnection = false connection?.dispose() connection = null diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsHead.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsHead.kt index a24c0e0a..c13a7cd3 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsHead.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/EthereumWsHead.kt @@ -45,7 +45,6 @@ class EthereumWsHead( } override fun stop() { - ws.close() subscription?.dispose() subscription = null }