You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2021/11/19 11:29:54 UTC

[GitHub] [incubator-brpc] dylanzhang opened a new issue #1610: 在brpc server中返回204时,body不为空

dylanzhang opened a new issue #1610:
URL: https://github.com/apache/incubator-brpc/issues/1610


   **Describe the bug (描述bug)**
   在brpc server中返回204时,body不为空,不符合http规范,容易导致相关客户端断连接,引起平响开销和大量占用TIME_WAIT
   
   **To Reproduce (复现方法)**
   在example/echo_c++的server.cpp第60行,添加 cntl->http_response().set_status_code(brpc::HTTP_STATUS_NO_CONTENT); 以期望返回结果为204
   ![image](https://user-images.githubusercontent.com/2951936/142614915-11403e8b-7da5-48eb-98a6-74c4ce5cffa2.png)
   
   结果确实是返回204了,但在抓包中发现,body是有内容的,不符合204的规范要求,导致相关服务会关闭长连接,抓包结果如下
   ![image](https://user-images.githubusercontent.com/2951936/142615236-0ed767d7-59d1-4146-8aa7-f3c35881d3f5.png)
   
   
   **Expected behavior (期望行为)**
   在返回204时,body应该为空,想请教一下,这个问题怎么修复呢?
   
   **Versions (各种版本)**
   OS:Ubuntu 18.04
   Compiler: gcc 7.5
   brpc: v0.9.7
   protobuf: 3
   
   **Additional context/screenshots (更多上下文/截图)**
   
   


-- 
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: dev-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] dylanzhang removed a comment on issue #1610: 在brpc server中返回204时,body不为空

Posted by GitBox <gi...@apache.org>.
dylanzhang removed a comment on issue #1610:
URL: https://github.com/apache/incubator-brpc/issues/1610#issuecomment-975174580


   请问一下,这个在后续迭代中有计划要升级吗?


-- 
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: dev-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] serverglen commented on issue #1610: 在brpc server中返回204时,body不为空

Posted by GitBox <gi...@apache.org>.
serverglen commented on issue #1610:
URL: https://github.com/apache/incubator-brpc/issues/1610#issuecomment-975191596


   > > > > ```c++
   > > > > if (some_condition) {
   > > > >     cntl->http_response().set_status_code(brpc::HTTP_STATUS_NO_CONTENT);
   > > > >     return ;
   > > > > }
   > > > > ```
   > > > 
   > > > 
   > > > 我这么实现也不行,body会有{}占用两个字节
   > > 
   > > 
   > > 那你可以尝试修改~HttpResponseSender()的实现 https://github.com/apache/incubator-brpc/blob/master/src/brpc/policy/http_rpc_protocol.cpp#L706
   > 
   > 请问一下,这个在后续迭代中有计划要升级吗?
   
   我理解可以在框架中兼容下,你要是着急的话,可以自己先改,然后提个PR。


-- 
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: dev-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] serverglen removed a comment on issue #1610: 在brpc server中返回204时,body不为空

Posted by GitBox <gi...@apache.org>.
serverglen removed a comment on issue #1610:
URL: https://github.com/apache/incubator-brpc/issues/1610#issuecomment-975191028


   > 
   
   我理解可以在框架中兼容下,你要是着急的话可以自己改,然后提个PR。


-- 
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: dev-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] serverglen edited a comment on issue #1610: 在brpc server中返回204时,body不为空

Posted by GitBox <gi...@apache.org>.
serverglen edited a comment on issue #1610:
URL: https://github.com/apache/incubator-brpc/issues/1610#issuecomment-974123240


   > > ```c++
   > > if (some_condition) {
   > >     cntl->http_response().set_status_code(brpc::HTTP_STATUS_NO_CONTENT);
   > >     return ;
   > > }
   > > ```
   > 
   > 我这么实现也不行,body会有{}占用两个字节
   
   那你可以尝试修改~HttpResponseSender()的实现
   https://github.com/apache/incubator-brpc/blob/master/src/brpc/policy/http_rpc_protocol.cpp#L706 
   


-- 
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: dev-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] dylanzhang commented on issue #1610: 在brpc server中返回204时,body不为空

Posted by GitBox <gi...@apache.org>.
dylanzhang commented on issue #1610:
URL: https://github.com/apache/incubator-brpc/issues/1610#issuecomment-974132867


   > > > ```c++
   > > > if (some_condition) {
   > > >     cntl->http_response().set_status_code(brpc::HTTP_STATUS_NO_CONTENT);
   > > >     return ;
   > > > }
   > > > ```
   > > 
   > > 我这么实现也不行,body会有{}占用两个字节
   > 
   > 那你可以尝试修改~HttpResponseSender()的实现
   > https://github.com/apache/incubator-brpc/blob/master/src/brpc/policy/http_rpc_protocol.cpp#L706 
   > 
   
   这个是企业应用,有官方修复版吗?


-- 
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: dev-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] serverglen commented on issue #1610: 在brpc server中返回204时,body不为空

Posted by GitBox <gi...@apache.org>.
serverglen commented on issue #1610:
URL: https://github.com/apache/incubator-brpc/issues/1610#issuecomment-974083483


   ```c++
   if (some_condition) {
       cntl->http_response().set_status_code(brpc::HTTP_STATUS_NO_CONTENT);
       return ;
   }
   ```
   
   


-- 
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: dev-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] dylanzhang commented on issue #1610: 在brpc server中返回204时,body不为空

Posted by GitBox <gi...@apache.org>.
dylanzhang commented on issue #1610:
URL: https://github.com/apache/incubator-brpc/issues/1610#issuecomment-975174731


   > > > ```c++
   > > > if (some_condition) {
   > > >     cntl->http_response().set_status_code(brpc::HTTP_STATUS_NO_CONTENT);
   > > >     return ;
   > > > }
   > > > ```
   > > 
   > > 
   > > 我这么实现也不行,body会有{}占用两个字节
   > 
   > 那你可以尝试修改~HttpResponseSender()的实现 https://github.com/apache/incubator-brpc/blob/master/src/brpc/policy/http_rpc_protocol.cpp#L706
   
   请问一下,这个在后续迭代中有计划要升级吗?
   
   


-- 
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: dev-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] serverglen commented on issue #1610: 在brpc server中返回204时,body不为空

Posted by GitBox <gi...@apache.org>.
serverglen commented on issue #1610:
URL: https://github.com/apache/incubator-brpc/issues/1610#issuecomment-975191028


   > 
   
   我理解可以在框架中兼容下,你要是着急的话可以自己改,然后提个PR。


-- 
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: dev-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] dylanzhang commented on issue #1610: 在brpc server中返回204时,body不为空

Posted by GitBox <gi...@apache.org>.
dylanzhang commented on issue #1610:
URL: https://github.com/apache/incubator-brpc/issues/1610#issuecomment-974111535


   > ```c++
   > if (some_condition) {
   >     cntl->http_response().set_status_code(brpc::HTTP_STATUS_NO_CONTENT);
   >     return ;
   > }
   > ```
   > 
   > 
   
   我这么实现也不行,body会有{}占用两个字节


-- 
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: dev-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] dylanzhang edited a comment on issue #1610: 在brpc server中返回204时,body不为空

Posted by GitBox <gi...@apache.org>.
dylanzhang edited a comment on issue #1610:
URL: https://github.com/apache/incubator-brpc/issues/1610#issuecomment-974132867


   > > > ```c++
   > > > if (some_condition) {
   > > >     cntl->http_response().set_status_code(brpc::HTTP_STATUS_NO_CONTENT);
   > > >     return ;
   > > > }
   > > > ```
   > > 
   > > 我这么实现也不行,body会有{}占用两个字节
   > 
   > 那你可以尝试修改~HttpResponseSender()的实现
   > https://github.com/apache/incubator-brpc/blob/master/src/brpc/policy/http_rpc_protocol.cpp#L706 
   > 
   
   这个是企业应用,有官方修复版吗?这个毕竟是不符合http规范的,在实际线上使用时,下游有很多稳定性问题


-- 
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: dev-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] serverglen commented on issue #1610: 在brpc server中返回204时,body不为空

Posted by GitBox <gi...@apache.org>.
serverglen commented on issue #1610:
URL: https://github.com/apache/incubator-brpc/issues/1610#issuecomment-974123240


   > > ```c++
   > > if (some_condition) {
   > >     cntl->http_response().set_status_code(brpc::HTTP_STATUS_NO_CONTENT);
   > >     return ;
   > > }
   > > ```
   > 
   > 我这么实现也不行,body会有{}占用两个字节
   
   那你可以尝试修改~HttpResponseSender()的实现https://github.com/apache/incubator-brpc/blob/master/src/brpc/policy/http_rpc_protocol.cpp#L706 
   


-- 
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: dev-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] dylanzhang commented on issue #1610: 在brpc server中返回204时,body不为空

Posted by GitBox <gi...@apache.org>.
dylanzhang commented on issue #1610:
URL: https://github.com/apache/incubator-brpc/issues/1610#issuecomment-975174580


   请问一下,这个在后续迭代中有计划要升级吗?


-- 
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: dev-unsubscribe@brpc.apache.org

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



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