public void start(){
//創建兩個執行緒組
NioEventLoopGroup boss = new NioEventLoopGroup();
NioEventLoopGroup work = new NioEventLoopGroup();
try{
ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.channel(NioServerSocketChannel.class);
bootstrap.handler(new LoggingHandler(LogLevel.DEBUG));
bootstrap.group(boss,work);
bootstrap.childHandler(new NettyChannelInitializer(cloudWsiController,prefix,nettyUtils));
ChannelFuture channelFuture = bootstrap.bind(port).sync();
logger.info("netty server start .......");
channelFuture.channel().closeFuture().sync();
}catch (InterruptedException e){
e.printStackTrace();
logger.warn("運行出錯,關閉連接:"+e.getMessage());
// boss.shutdownGracefully();
// work.shutdownGracefully();
}finally {
boss.shutdownGracefully();
work.shutdownGracefully();
logger.info("websocket服務器已關閉");
}
}
無法注冊到euaeka
public void start(){
//創建兩個執行緒組
NioEventLoopGroup boss = new NioEventLoopGroup();
NioEventLoopGroup work = new NioEventLoopGroup();
try{
ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.channel(NioServerSocketChannel.class);
bootstrap.handler(new LoggingHandler(LogLevel.DEBUG));
bootstrap.group(boss,work);
bootstrap.childHandler(new NettyChannelInitializer(cloudWsiController,prefix,nettyUtils));
ChannelFuture channelFuture = bootstrap.bind(port).sync();
logger.info("netty server start .......");
// channelFuture.channel().closeFuture().sync();
}catch (InterruptedException e){
e.printStackTrace();
logger.warn("運行出錯,關閉連接:"+e.getMessage());
boss.shutdownGracefully();
work.shutdownGracefully();
}finally {
// boss.shutdownGracefully();
// work.shutdownGracefully();
// logger.info("websocket服務器已關閉");
}
}
這樣修改后經常出現java.nio.channels.ClosedChannelException 例外(An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception)
請問有什么更好的解決方法嗎?
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/121229.html
標籤:Web 開發
上一篇:idea創建Maven專案出問題
下一篇:新人求幫忙
