problem: reconnects too fast to a faulty WS connection
This commit is contained in:
@@ -225,12 +225,18 @@ open class WsConnection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun handle(inbound: WebsocketInbound, outbound: WebsocketOutbound): Publisher<Void> {
|
fun handle(inbound: WebsocketInbound, outbound: WebsocketOutbound): Publisher<Void> {
|
||||||
// restart backoff after connection
|
var read = false
|
||||||
currentBackOff = reconnectBackoff.start()
|
|
||||||
|
|
||||||
val consumer = inbound
|
val consumer = inbound
|
||||||
.aggregateFrames(msgSizeLimit)
|
.aggregateFrames(msgSizeLimit)
|
||||||
.receiveFrames()
|
.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() }
|
.map { ByteBufInputStream(it.content()).readAllBytes() }
|
||||||
.flatMap {
|
.flatMap {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user