- // TODO we should also read from error stream and at least log from that
-
- ClientChannel localChannel = channel;
- sshReadAsyncListener = new AsyncSshHandlerReader(() -> AsyncSshHandler.this.disconnect(ctx, ctx.newPromise()),
- msg -> ctx.fireChannelRead(msg), localChannel.toString(), localChannel.getAsyncOut());
-
- // if readAsyncListener receives immediate close,
- // it will close this handler and closing this handler sets channel variable to null
- if (channel != null) {
- sshWriteAsyncHandler = new AsyncSshHandlerWriter(channel.getAsyncIn());
- ctx.fireChannelActive();
- }
+ sshWriteAsyncHandler = new AsyncSshHandlerWriter(channel.getAsyncIn());
+ ctx.fireChannelActive();
+ channel.onClose(() -> disconnect(ctx, ctx.newPromise()));