Skip to content

Commit

Permalink
problem: reconnects too fast to a faulty WS connection
Browse files Browse the repository at this point in the history
  • Loading branch information
splix committed Aug 25, 2022
1 parent ff2ec4e commit 58524de
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,18 @@ open class WsConnection(
}

fun handle(inbound: WebsocketInbound, outbound: WebsocketOutbound): Publisher<Void> {
// 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 {
Expand Down

0 comments on commit 58524de

Please sign in to comment.