Skip to content

Netty channel hangs after sending a payload of size > 16 MB #742

Closed

Description

@xiazuojie

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.

Activity

  1. self-assigned this
    on Feb 12, 2020
  2. OlegDokuka commented on Feb 12, 2020

    @OlegDokuka
    Member

    I will take a look at that.

    Is not that a reactor-netty bug?

    cc/ @violetagg

  3. xiazuojie commented on Feb 12, 2020

    @xiazuojie
    ContributorAuthor

    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.

  4. violetagg commented on Feb 12, 2020

    @violetagg
    Contributor

    I will take a look at that.

    Is not that a reactor-netty bug?

    cc/ @violetagg

    Not seen so far.

  5. 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
  6. 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
  7. rstoyanchev commented on Apr 3, 2020

    @rstoyanchev
    Contributor

    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.

  8. added this to the 1.0 milestone on Apr 5, 2020
  9. OlegDokuka commented on Apr 5, 2020

    @OlegDokuka
    Member

    Due to what I see, there are two issues:

    1. 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.

      1. 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
      2. 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

  10. rstoyanchev commented on Apr 8, 2020

    @rstoyanchev
    Contributor

    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"?

  11. OlegDokuka commented on Apr 8, 2020

    @OlegDokuka
    Member

    @rstoyanchev

    An additional check in WebSocket transports

    This check is already present, no need to put extra one

  12. rstoyanchev commented on Apr 8, 2020

    @rstoyanchev
    Contributor

    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.

  13. OlegDokuka commented on Apr 15, 2020

    @OlegDokuka
    Member

    @xiazuojie RC-7 should have fixed your issue. Please check it and feel free to reopen this issue if the bug was not fixes

  14. modified the milestones: 1.0, 1.0.0-RC7 on Apr 17, 2020
  15. removed this from the 1.0 RC7 milestone on Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugsupersededIssue is superseded by another

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions