を使用するプロジェクトがNettyあり、いくつかの問題があります。
connectionがしばらくアイドル状態の場合、は自動的にconnection閉じるかどうか。勝手に閉まる場合、閉まる時間をどうやって設定すればいいですか?
5 つのスレッドがあり、100 個のデータを送信します。彼らは同じチャンネルを使用します。
/** release connect*/
public void closeConnect(ChannelFuture writeFuture){
if(writeFuture != null){
writeFuture.awaitUninterruptibly();
}
future.getChannel().close();
future.getChannel().getCloseFuture().awaitUninterruptibly();
client.releaseExternalResources();
}
//write data
ChannelFuture future = Channels.write(data);
closeConnect(future);
上記のコードはcloseChannelexception. 私の質問は、どうすれば例外を回避できますか?
また、ReadTimeoutHandlerクライアントで使用し、timeout= 5 を設定し、スレッドを 6 秒間スリープさせると、その後ReadTimeoutException発生します。を呼び出すe.getChannel().close()と、closeChannelException. 自分で例外を処理したり、例外なく接続を閉じたりするにはどうすればよいですか?