diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/WsConnection.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/WsConnection.kt index d09cda9e7..46743d221 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/WsConnection.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/WsConnection.kt @@ -221,12 +221,18 @@ open class WsConnection( } fun handle(inbound: WebsocketInbound, outbound: WebsocketOutbound): Publisher { - // restart backoff after connection - currentBackOff = reconnectBackoff.start() - + var read = false val consumer = inbound .aggregateFrames(msgSizeLimit) .receiveFrames() + .doOnNext { + if (!read) { + // restart backoff only after a successful read from the connection, + // otherwise it may restart it even if the connection is faulty + currentBackOff = reconnectBackoff.start() + read = true + } + } .map { ByteBufInputStream(it.content()).readAllBytes() } .flatMap { try {