GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — InboundHttp2ToHttpAdapter maxContentLength exceeded causes connection error · Issue #11994 · netty/netty

InboundHttp2ToHttpAdapter maxContentLength exceeded causes connection error #11994

New issue
Copy link
New issue
Copy link
Closed
#16629
Closed
InboundHttp2ToHttpAdapter maxContentLength exceeded causes connection error#11994
#16629
Copy link
Milestone
4.1.133.Final

Description

@BrianRothermich
BrianRothermich
opened on Jan 12, 2022
Issue body actions

Expected behavior

When using InboundHttp2ToHttpAdapter, sending a payload that exceeds maxContentLength should return a status code of 413 before closing the stream.

Actual behavior

If a message payload exceeds maxContentLength, a connection error is thrown causing a GO_AWAY to be sent. This is confusing behavior to clients and we have seen load balancers treat these errors as 5xx errors when it's expected to be a client (4xx) error.

netty/codec-http2/src/main/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapter.java

Lines 237 to 240 in c6e65cc

if (content.readableBytes() > maxContentLength - dataReadableBytes) {
throw connectionError(INTERNAL_ERROR,
"Content length exceeded max of %d for stream id %d", maxContentLength, streamId);
}

netty/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ConnectionHandler.java

Lines 665 to 678 in c6e65cc

protected void onConnectionError(ChannelHandlerContext ctx, boolean outbound,
Throwable cause, Http2Exception http2Ex) {
if (http2Ex == null) {
http2Ex = new Http2Exception(INTERNAL_ERROR, cause.getMessage(), cause);
}
ChannelPromise promise = ctx.newPromise();
ChannelFuture future = goAway(ctx, http2Ex, ctx.newPromise());
if (http2Ex.shutdownHint() == Http2Exception.ShutdownHint.GRACEFUL_SHUTDOWN) {
doGracefulShutdown(ctx, future, promise);
} else {
future.addListener(newClosingChannelFutureListener(ctx, promise));
}
}

Curious if there's something I'm missing about why this results in a connection error.

Steps to reproduce

Send a payload exceeding maxContentLength configured here to a pipeline using InboundHttp2ToHttpAdapter:

netty/codec-http2/src/main/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapterBuilder.java

Lines 36 to 39 in c6e65cc

@Override
public InboundHttp2ToHttpAdapterBuilder maxContentLength(int maxContentLength) {
return super.maxContentLength(maxContentLength);
}

Netty version

4.1.73.Final

Activity

Next
  1. normanmaurer commented on Jan 13, 2022

    @normanmaurer
    normanmaurer
    on Jan 13, 2022
    Member
    More actions

    @BrianRothermich are you suggesting to use a stream error ?

  2. BrianRothermich commented on Jan 13, 2022

    @BrianRothermich
    BrianRothermich
    on Jan 13, 2022
    Author
    More actions

    @normanmaurer I'm primarily just suggesting that a 413 status code should be returned for this case. It does seem like this would fall under a stream error, though.

  3. wanglunhui2012 commented on Jan 13, 2022

    @wanglunhui2012
    wanglunhui2012
    on Jan 13, 2022
    Contributor
    More actions

    @normanmaurer @BrianRothermich Maybe FRAME_SIZE_ERROR.

  4. normanmaurer commented on Jan 13, 2022

    @normanmaurer
    normanmaurer
    on Jan 13, 2022
    Member
    More actions

    @wanglunhui2012 @BrianRothermich maybe ENHANCE_YOUR_CALM would be better ?

  5. BrianRothermich commented on Jan 14, 2022

    @BrianRothermich
    BrianRothermich
    on Jan 14, 2022
    Author
    More actions

    maybe ENHANCE_YOUR_CALM would be better ?

    sgtm. I'm happy to provide a PR.

  6. normanmaurer commented on Jan 14, 2022

    @normanmaurer
    normanmaurer
    on Jan 14, 2022
    Member
    More actions

    @BrianRothermich sounds good!

  7. normanmaurer
    added this to the 4.1.74.Final milestone on Jan 14, 2022
  8. normanmaurer
    modified the milestones: 4.1.74.Final, 4.1.75.Final on Feb 8, 2022
  9. normanmaurer
    modified the milestones: 4.1.75.Final, 4.1.76.Final on Mar 10, 2022
  10. chrisvest
    modified the milestones: 4.1.76.Final, 4.1.77.Final on Apr 12, 2022
  11. normanmaurer
    modified the milestones: 4.1.77.Final, 4.1.78.Final on May 6, 2022
  12. 97 remaining items

  13. normanmaurer
    modified the milestones: 4.1.130.Final, 4.1.131.Final on Dec 15, 2025
  14. normanmaurer
    modified the milestones: 4.1.131.Final, 4.1.132.Final on Feb 6, 2026
  15. normanmaurer
    modified the milestones: 4.1.132.Final, 4.1.133.Final on Mar 25, 2026
  16. daguimu
    added 2 commits that reference this issue on Mar 26, 2026

    fix: use stream error instead of connection error when maxContentLeng…

    This issue will close once commit 3f0b146 is merged into the '4.1' branch.
    3f0b146

    fix: use stream error instead of connection error when maxContentLeng…

    This issue will close once commit 0a5d42e is merged into the '4.1' branch.
    0a5d42e
  17. normanmaurer
    added a commit that references this issue on Apr 10, 2026

    Use stream error for maxContentLength exceeded in InboundHttp2ToHttpA…

    This issue will close once commit d8dd805 is merged into the '4.2' branch.
    d8dd805
  18. netty-project-bot
    added 2 commits that reference this issue on Apr 10, 2026

    Use stream error for maxContentLength exceeded in InboundHttp2ToHttpA…

    This issue will close once commit 63edd7b is merged into the '4.2' branch.
    63edd7b

    Use stream error for maxContentLength exceeded in InboundHttp2ToHttpA…

    This issue will close once commit e1df9cc is merged into the '4.2' branch.
    e1df9cc
  19. chrisvest
    closed this as completedin #16629on Apr 10, 2026
  20. chrisvest
    added 2 commits that reference this issue on Apr 11, 2026

    Auto-port 4.2: Use stream error for maxContentLength exceeded in Inbo…

    This issue will close once commit 8f51ad3 is merged into the '4.1' branch.
    8f51ad3

    Auto-port 5.0: Use stream error for maxContentLength exceeded in Inbo…

    This issue will close once commit 5aa5d72 is merged into the '4.2' branch.
    5aa5d72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      • 4.1.133.Final

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.