problem: drops connection because of large frames
This commit is contained in:
@@ -170,6 +170,11 @@ class EthereumWsFactory(
|
|||||||
WebsocketClientSpec.builder()
|
WebsocketClientSpec.builder()
|
||||||
.handlePing(true)
|
.handlePing(true)
|
||||||
.compress(false)
|
.compress(false)
|
||||||
|
// Default is 65_536, but Geth responds with larger frames,
|
||||||
|
// and connection gets dropped with:
|
||||||
|
// > io.netty.handler.codec.http.websocketx.CorruptedWebSocketFrameException: Max frame length of 65536 has been exceeded
|
||||||
|
// It's unclear what is a right limit here, but 1mb seems to be working
|
||||||
|
.maxFramePayloadLength(1024 * 1024)
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.uri(uri)
|
.uri(uri)
|
||||||
@@ -184,9 +189,9 @@ class EthereumWsFactory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun handle(inbound: WebsocketInbound, outbound: WebsocketOutbound): Publisher<Void> {
|
fun handle(inbound: WebsocketInbound, outbound: WebsocketOutbound): Publisher<Void> {
|
||||||
val consumer = inbound.aggregateFrames()
|
val consumer = inbound
|
||||||
// accept up to 1Mb messages
|
// Accept up to 15Mb messages, same config is used by Geth
|
||||||
.aggregateFrames(16 * 65_536)
|
.aggregateFrames(15 * 1024 * 1024)
|
||||||
.receiveFrames()
|
.receiveFrames()
|
||||||
.map { ByteBufInputStream(it.content()).readAllBytes() }
|
.map { ByteBufInputStream(it.content()).readAllBytes() }
|
||||||
.flatMap {
|
.flatMap {
|
||||||
@@ -203,7 +208,7 @@ class EthereumWsFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onErrorResume { t ->
|
.onErrorResume { t ->
|
||||||
log.warn("Connection dropped to $uri. Error: ${t.message}")
|
log.warn("Connection dropped to $uri. Error: ${t.message}", t)
|
||||||
// going to try to reconnect later
|
// going to try to reconnect later
|
||||||
tryReconnectLater()
|
tryReconnectLater()
|
||||||
// completes current outbound flow
|
// completes current outbound flow
|
||||||
|
|||||||
Reference in New Issue
Block a user