You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Netty channel hangs after sending a payload of size > 16 MB #742
The max allowed size of a frame is 16 MB (according to this). If a payload is larger than 16 MB, encoding it to a frame will fail with an exception "Length is larger than 24 bits".
However, this exception is not properly handled by MonoSendMany. A single such exception (encoding happens inside applying MapFuseableSubscriber#mapper) will terminate the subscription. No payloads will be sent to netty channel after (due to subscription terminated).
In short, a single payload of size >= 16 MB will make the channel hang forever. And worse, there is no error log at all when this happens.
According to spec, large payloads should be fragmented to more frames. However, this feature is currently not implemented transparently.
The feature used to be in rsocket-java (SendPublisher) , later moved to reactor-netty. I think it's more about RSocket Java not properly handling payloads > 16MB.
changed the title [-]Netty channel hangs if sending a payload of size >= 16 MB[/-][+]Netty channel hangs if sending a payload of size > 16 MB[/+]on Feb 12, 2020
changed the title [-]Netty channel hangs if sending a payload of size > 16 MB[/-][+]Netty channel hangs after sending a payload of size > 16 MB[/+]on Feb 13, 2020
According to spec, large payloads should be fragmented to more frames. However, this feature is currently not implemented transparently.
There is a fragmentation(..) setting on RSocketFactory and if you set that it should fragment. If you're keeping it at 0 intentionally (it is also the default) then yes it should be handled better.
Lack of documentation on what is the defaults in RSocket-Java and that there is no fragmentation by default. It means that all the frames that exit 16 MB size is illegal.
We have a bug in TCP connection which tries to add frame length at the transport level and throws an exception because the encoded frame was not validated and just simply got encoded and sent (lack of Validation on RSocket level). Therefore, FrameLengthFlightweight does late validation and throws an exception
We have a bug in WebSocket which sends that frame and then the responder is not able to reassemble it back
Note, in both (2,3) we get connection termination instead of logical stream termination with the proper message
Given #768 to validate payload length earlier, and #769 to document, what's actually left here?
Payloads with invalid length should not be able to get through, but arguably the transport layer should have independent validation. An additional check in WebSocket transports perhaps to prevent sending a frame that's too large? If that's all it is maybe this can become a task under #768 and be closed as "superseded"?
Activity
OlegDokuka commentedon Feb 12, 2020
I will take a look at that.
Is not that a reactor-netty bug?
cc/ @violetagg
xiazuojie commentedon Feb 12, 2020
The feature used to be in rsocket-java (SendPublisher) , later moved to reactor-netty. I think it's more about RSocket Java not properly handling payloads > 16MB.
violetagg commentedon Feb 12, 2020
Not seen so far.
[-]Netty channel hangs if sending a payload of size >= 16 MB[/-][+]Netty channel hangs if sending a payload of size > 16 MB[/+][-]Netty channel hangs if sending a payload of size > 16 MB[/-][+]Netty channel hangs after sending a payload of size > 16 MB[/+]rstoyanchev commentedon Apr 3, 2020
There is a
fragmentation(..)setting onRSocketFactoryand if you set that it should fragment. If you're keeping it at 0 intentionally (it is also the default) then yes it should be handled better.OlegDokuka commentedon Apr 5, 2020
Due to what I see, there are two issues:
Lack of documentation on what is the defaults in RSocket-Java and that there is no fragmentation by default. It means that all the frames that exit 16 MB size is illegal.
FrameLengthFlightweightdoes late validation and throws an exceptionNote, in both (2,3) we get connection termination instead of logical stream termination with the proper message
rstoyanchev commentedon Apr 8, 2020
Given #768 to validate payload length earlier, and #769 to document, what's actually left here?
Payloads with invalid length should not be able to get through, but arguably the transport layer should have independent validation. An additional check in WebSocket transports perhaps to prevent sending a frame that's too large? If that's all it is maybe this can become a task under #768 and be closed as "superseded"?
OlegDokuka commentedon Apr 8, 2020
@rstoyanchev
This check is already present, no need to put extra one
rstoyanchev commentedon Apr 8, 2020
I just noticed the "Linked pull requests" on the right, and in the timeline above it says this will be fixed by #768. All good.
OlegDokuka commentedon Apr 15, 2020
@xiazuojie RC-7 should have fixed your issue. Please check it and feel free to reopen this issue if the bug was not fixes