Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Resteasy Netty服务器在第一次客户端断开连接后未握手_Java_Ssl_Jax Rs_Netty_Resteasy - Fatal编程技术网

Java Resteasy Netty服务器在第一次客户端断开连接后未握手

Java Resteasy Netty服务器在第一次客户端断开连接后未握手,java,ssl,jax-rs,netty,resteasy,Java,Ssl,Jax Rs,Netty,Resteasy,我在使用带有SSL的NettyJaxrsServer时遇到问题。第一个请求成功,后续请求超时。通常,如果我使用curl发送HTTPS请求,只有第一个调用通过。我和wireshark核实了一下,看看发生了什么。服务器仅对第一个请求执行握手。对于第二个请求,客户端发送一条“Hello”消息,服务器不继续握手。即使在客户端断开连接之后,服务器似乎仍在保持SSL会话 我验证了代码,对于每个客户端连接,在客户端管道中插入一个新的SSLHandler,但使用相同的SSLEngine final SSLEn

我在使用带有SSL的NettyJaxrsServer时遇到问题。第一个请求成功,后续请求超时。通常,如果我使用curl发送HTTPS请求,只有第一个调用通过。我和wireshark核实了一下,看看发生了什么。服务器仅对第一个请求执行握手。对于第二个请求,客户端发送一条“Hello”消息,服务器不继续握手。即使在客户端断开连接之后,服务器似乎仍在保持SSL会话

我验证了代码,对于每个客户端连接,在客户端管道中插入一个新的SSLHandler,但使用相同的SSLEngine

final SSLEngine engine = sslContext.createSSLEngine();
engine.setUseClientMode(false);
bootstrap.group(eventLoopGroup)
         .channel(NioServerSocketChannel.class)
         .childHandler(new ChannelInitializer<SocketChannel>() {
            @Override
            public void initChannel(SocketChannel ch) throws Exception {
               ch.pipeline().addFirst(new SslHandler(engine));
               ch.pipeline().addLast(channelHandlers.toArray(new ChannelHandler[channelHandlers.size()]));
               ch.pipeline().addLast(new HttpRequestDecoder());
               ch.pipeline().addLast(new HttpObjectAggregator(maxRequestSize));
               ch.pipeline().addLast(new HttpResponseEncoder());
               ch.pipeline().addLast(new RestEasyHttpRequestDecoder(dispatcher.getDispatcher(), root, RestEasyHttpRequestDecoder.Protocol.HTTPS));
               ch.pipeline().addLast(new RestEasyHttpResponseEncoder());
               ch.pipeline().addLast(eventExecutor, new RequestHandler(dispatcher));
           }
        })
        .option(ChannelOption.SO_BACKLOG, backlog)
        .childOption(ChannelOption.SO_KEEPALIVE, true);
final SSLEngine引擎=sslContext.createSSLEngine();
engine.setUseClientMode(假);
bootstrap.group(eventLoopGroup)
.channel(NioServerSocketChannel.class)
.childHandler(新的通道初始值设定项(){
@凌驾
public void initChannel(SocketChannel ch)引发异常{
通道管道().addFirst(新SslHandler(发动机));
ch.pipeline().addLast(channelHandlers.toArray(新的ChannelHandler[channelHandlers.size()]);
ch.pipeline().addLast(新的HttpRequestDecoder());
ch.pipeline().addLast(新的HttpObjectAggregator(maxRequestSize));
ch.pipeline().addLast(新的HttpResponseEncoder());
ch.pipeline().addLast(新的resteasyhtprequestdecoder(dispatcher.getDispatcher(),root,resteasyhtprequestdecoder.Protocol.HTTPS));
ch.pipeline().addLast(新的RestEasyHttpResponseEncoder());
ch.pipeline().addLast(eventExecutor,new RequestHandler(dispatcher));
}
})
.option(ChannelOption.SO_BACKLOG,BACKLOG)
.childOption(ChannelOption.SO_KEEPALIVE,true);
从Netty文档中,我了解到每个新的客户端连接都应使用新的SSLEngine:

重新启动会话

要重新启动SSL会话,必须从ChannelPipeline中删除现有的已关闭的SslHandler,将带有新SSLEngine的新SslHandler插入管道,并按照第一节中的说明启动握手过程

有人能解释这种行为吗?或者这是Netty resteasy服务器中的一个bug

使用版本:resteasy-netty4 3.0.11.Final