接続エラー時にクライアントサーバーの処理をテストしています。IOExceptionでNetty ChannelFuture.operationComplete()が呼び出されない
クライアント側では、クライアントからサーバーにメッセージを送信するときにLANケーブルを外したとき、私のChannelFuture(以下)が呼び出されません。 私が期待したのは、例外は私のChannelFutureに捕らえられていたので、operationCompleteでそれを扱うことができました。
代わりに、クライアントのパイプライン内の最後のアップストリームハンドラでしか捕捉されません。 何か間違っていますか?またはこれはNetty 3.2.4の問題ですか?
私はLANケーブルを抜いたときに、私はハンドラ内で取得しています例外:
java.io.IOException: An existing connection was forcibly closed by the remote host
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:25)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:198)
at sun.nio.ch.IOUtil.read(IOUtil.java:166)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:243)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:321)
at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:280)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:200)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
マイChannelFuture:
ChannelFuture future = Channels.write(channel, message);
future.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (!future.isSuccess()) {
LOG.error("Client failed to send message", future.getCause());
future.getChannel().close();
}
}
});
私は、次の手順を行う場合は、次のChannels.write 2.プルLANケーブル 3. Channels.writeとのaddListenerが続いのみUpstreamHandler.exceptionCaughtを() を実行できるようにする前に、 1.追加ブレークポイントをChannelFutureを誘発しますではない。 メッセージが失われ、サーバーがメッセージを受信しません。 – DarVar