Netty 无法在频道中发送第二个请求
Netty cannot send second request in a channel
我尝试在 netty 中模拟 http 握手,但客户端无法发送第二个请求。
这是流程
Client -> request1 -> Server
Client <- response <- server
Client -> request2 -> Server (cannot see data is sent)
Client <- response <- server
这是代码
https://github.com/Tonghua-Li/Netty-Handshake-Test/tree/master/src/main/java
服务器和客户端日志位于 git 存储库的根文件夹中
https://github.com/Tonghua-Li/Netty-Handshake-Test/blob/master/client.log
从日志中,请求 2 已准备好并刷新到端口 80(服务器)。但我没有在客户端日志中看到十六进制块作为请求 1
sending request 2
Sep 24, 2019 6:02:40 PM io.netty.handler.logging.LoggingHandler flush
INFO: [id: 0xd6797f27, L:/127.0.0.1:60893 - R:/127.0.0.1:80] FLUSH
谢谢!
您需要创建 FullHttpRequest
个实例,或者您需要 "terminate" 您的 HttpRequest
和 LastHttpRequest
,然后再发送下一个 HttpRequest
。
如果您将 ChannelFutureListener
附加到 writeAndFlush(...)
返回的 ChannelFuture
,您将看到 ChannelFuture
失败,因为 "sequence of messages" 不是预期的。
我尝试在 netty 中模拟 http 握手,但客户端无法发送第二个请求。 这是流程
Client -> request1 -> Server
Client <- response <- server
Client -> request2 -> Server (cannot see data is sent)
Client <- response <- server
这是代码 https://github.com/Tonghua-Li/Netty-Handshake-Test/tree/master/src/main/java
服务器和客户端日志位于 git 存储库的根文件夹中 https://github.com/Tonghua-Li/Netty-Handshake-Test/blob/master/client.log
从日志中,请求 2 已准备好并刷新到端口 80(服务器)。但我没有在客户端日志中看到十六进制块作为请求 1
sending request 2
Sep 24, 2019 6:02:40 PM io.netty.handler.logging.LoggingHandler flush
INFO: [id: 0xd6797f27, L:/127.0.0.1:60893 - R:/127.0.0.1:80] FLUSH
谢谢!
您需要创建 FullHttpRequest
个实例,或者您需要 "terminate" 您的 HttpRequest
和 LastHttpRequest
,然后再发送下一个 HttpRequest
。
如果您将 ChannelFutureListener
附加到 writeAndFlush(...)
返回的 ChannelFuture
,您将看到 ChannelFuture
失败,因为 "sequence of messages" 不是预期的。