optimize: support http1 automatic keepalive setting#15019
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 3.3 #15019 +/- ##
============================================
- Coverage 60.76% 60.76% -0.01%
- Complexity 10866 10868 +2
============================================
Files 1882 1882
Lines 85983 85990 +7
Branches 12876 12878 +2
============================================
+ Hits 52246 52250 +4
- Misses 28289 28295 +6
+ Partials 5448 5445 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
|
||
| public class NettyHttp1Codec extends ChannelDuplexHandler { | ||
|
|
||
| boolean keepAlive; |
There was a problem hiding this comment.
private boolean keepAlive;
done
| private void doWriteMessage(ChannelHandlerContext ctx, HttpOutputMessage msg, ChannelPromise promise) { | ||
| if (HttpOutputMessage.EMPTY_MESSAGE == msg) { | ||
| ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT, promise); | ||
| if (!keepAlive) { |
There was a problem hiding this comment.
Not flipping the boolean will make the code better understood:
if (keepAlive) {
ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT, promise);
} else {
ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT, promise).addListener(ChannelFutureListener.CLOSE);
}There was a problem hiding this comment.
Not flipping the boolean will make the code better understood:
if (keepAlive) { ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT, promise); } else { ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT, promise).addListener(ChannelFutureListener.CLOSE); }
done
|
Could you please test whether SSE is work fine? |
In Spring, i can use SseEmitter to send messages, but how should this be done in Dubbo? Are there any related examples? |
What is the purpose of the change?
由于ab压测工具默认是短连接,当使用该工具压测时,针对短连接请求,没有将对应的channel设置该ChannelFutureListener.CLOSE listener时,将使ab压测工具进程hang住,故增加自动识别请求是否需要保持长连接来解决该问题。
Since the ab benchmarking tool uses short connections by default, when using this tool for benchmarking, if the corresponding channel is not set with the ChannelFutureListener.CLOSE listener for short connection requests, it will cause the ab benchmarking tool process to hang. Therefore, adding automatic recognition of whether the request needs to keep the connection alive can solve this problem.
Checklist