I've the following source: https://hastebin.com/ovekebahij.java
bootstrap.group( eventLoopGroup )
.channel( serverSocketChannelClass )
.option( ChannelOption.SO_KEEPALIVE, true )
.handler( new ChannelInitializer<NioServerSocketChannel>() {
@Override
protected void initChannel( NioServerSocketChannel nioServerSocketChannel ) throws Exception {
callback.onSuccess( preparePipeline( nioServerSocketChannel ) );
}
});
I don't know why but my log says me, that the server is successfully started. Each time I try to connect a client, it says that it cannot connect... anyone an Idea?
Thanks for each contribution.
Its because your server bootstrap method does not block and so close the socket after it was bound.
You should change the code to be:
Channel channel = bootstrap.bind(...).sync().channel();
...
channel.closeFuture().sync()
This will ensure the method will only return after the socket is closed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.