You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@brpc.apache.org by "imdouyu (via GitHub)" <gi...@apache.org> on 2025/12/18 03:30:15 UTC

[I] max_body_size逻辑不一致 (brpc)

imdouyu opened a new issue, #3177:
URL: https://github.com/apache/brpc/issues/3177

   ```
   DEFINE_uint64(max_body_size, 64 * 1024 * 1024,
                 "Maximum size of a single message body in all protocols");
   ```
   
   > A message from x.x.x.x:4096(protocol=baidu_std) is bigger than 67108864 bytes, the connection will be closed. Set max_body_size to allow bigger messages
   
   
   看代码定义说是对所有协议生效,但在测试中发现用h2:grpc没有上面消息过大的报错,用baidu_std就会有上面的错误,是对h2:grpc不检测吗
   
   <img width="553" height="892" alt="Image" src="https://github.com/user-attachments/assets/e9c230cf-fb34-4c90-976b-d8a2d2cbf759" />
   
   搜了代码也没发现
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@brpc.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@brpc.apache.org
For additional commands, e-mail: issues-help@brpc.apache.org


Re: [I] max_body_size逻辑不一致 (brpc)

Posted by "rajvarun77 (via GitHub)" <gi...@apache.org>.
rajvarun77 commented on issue #3177:
URL: https://github.com/apache/brpc/issues/3177#issuecomment-4687878377

   I dug into this. Confirming the report: `-max_body_size` is documented as "Maximum size of a single message body in **all protocols**," but the HTTP/2 path never enforces it.
   
   The length-prefixed protocols (`baidu_std`, `hulu`, `sofa`, `nshead`, `thrift`, `mongo`, `esp`, `streaming`) each reject early in their parser via `body_size > FLAGS_max_body_size` → `PARSE_ERROR_TOO_BIG_DATA`, because the wire format carries the total body length up front. `H2StreamContext::OnData` has no equivalent check — body bytes accumulate across DATA frames with only HTTP/2 flow control as a bound, and flow control is replenished mid-message (`WINDOW_UPDATE`), so it acts as backpressure, not a size cap. Note that protobuf's own limit is deliberately raised (`SetTotalBytesLimit(INT_MAX)` in `protocol.cpp`) on the assumption that `max_body_size` is the real gate — which the h2 path skips.
   
   Before opening a PR, I'd like to confirm the intended direction. Proposal: maintain a cumulative received-body byte counter in `H2StreamContext::OnData`, compare it against `FLAGS_max_body_size`, and fail the stream when exceeded — i.e. make h2 honor the existing flag rather than introducing a new one. The one nuance: the progressive-read path (`read_body_progressively()`) drains the body incrementally and is intended for large/unbounded streaming, so it should be exempt (or the cap applied per-drain rather than cumulatively).
   
   Two questions for maintainers:
   1. Is honoring `max_body_size` on the h2 path the desired behavior, or should the doc string be narrowed instead?
   2. Is exempting the progressive-read path acceptable?
   
   Happy to send the patch + unittest once the direction is confirmed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@brpc.apache.org
For additional commands, e-mail: issues-help@brpc.apache.org


Re: [I] max_body_size逻辑不一致 (brpc)

Posted by "two-headBoy (via GitHub)" <gi...@apache.org>.
two-headBoy commented on issue #3177:
URL: https://github.com/apache/brpc/issues/3177#issuecomment-6287955260

   #3382 好像已经解决了。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@brpc.apache.org
For additional commands, e-mail: issues-help@brpc.apache.org


Re: [I] max_body_size逻辑不一致 (brpc)

Posted by "chenBright (via GitHub)" <gi...@apache.org>.
chenBright closed issue #3177: max_body_size逻辑不一致
URL: https://github.com/apache/brpc/issues/3177


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@brpc.apache.org
For additional commands, e-mail: issues-help@brpc.apache.org