[NETCONF-905] NetconfSessionPromise reconnection failure Created: 13/Oct/22  Updated: 31/Oct/22  Resolved: 20/Oct/22

Status: Resolved
Project: netconf
Component/s: netconf
Affects Version/s: 3.0.6, 4.0.2
Fix Version/s: 3.0.7, 4.0.3, 2.0.17

Type: Bug Priority: Medium
Reporter: Sangwook Ha Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File karaf-netconf-905-102751-4-mod.log     Text File karaf-netconf-905-102751-4.log     Text File karaf-netconf-905.log     Text File karaf.log    
Issue Links:
Issue split
split from NETCONF-827 Mount loop when setting too low conne... Resolved

 Description   

The fix for NETCONF-827 addressed the race between channel message dispatch & timeout. However, NETCONF session negotiation can still fail putting NetconfSessionPromise in the failed state. Once this happens following reconnection attempts initiated by ReconnectStrategy all fail because of the failed state.

For example, the following log shows a case where session negotiation fails because NETCONF channel has been closed before hello message is sent:

2022-10-13T21:47:49,161 | INFO  | globalWorkerGroup-3-2 | AbstractNetconfSessionNegotiator | 258 - org.opendaylight.netconf.netty-util - 4.0.3.SNAPSHOT | Failed to send message <hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <capabilities>
        <capability>urn:ietf:params:netconf:capability:exi:1.0</capability>
        <capability>urn:ietf:params:netconf:base:1.1</capability>
        <capability>urn:ietf:params:netconf:base:1.0</capability>
    </capabilities>
</hello>
 on channel [id: 0x738232cc]
java.lang.IllegalStateException: Channel closed
	at org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandlerWriter.write(AsyncSshHandlerWriter.java:59) ~[bundleFile:?]
	at org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler.write(AsyncSshHandler.java:186) ~[bundleFile:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:709) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:792) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:702) ~[bundleFile:4.1.76.Final]
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:113) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:709) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:792) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:702) ~[bundleFile:4.1.76.Final]
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:113) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:790) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:758) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:808) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1025) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:306) ~[bundleFile:4.1.76.Final]
	at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.sendMessage(AbstractNetconfSessionNegotiator.java:340) ~[bundleFile:?]
	at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.start(AbstractNetconfSessionNegotiator.java:150) ~[bundleFile:?]
	at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.startNegotiation(AbstractNetconfSessionNegotiator.java:131) ~[bundleFile:?]
	at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.channelActive(AbstractNetconfSessionNegotiator.java:355) ~[bundleFile:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:230) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.access$200(AbstractChannelHandlerContext.java:61) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext$3.run(AbstractChannelHandlerContext.java:221) ~[bundleFile:4.1.76.Final]
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) ~[bundleFile:4.1.76.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503) ~[bundleFile:4.1.76.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) ~[bundleFile:4.1.76.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[bundleFile:4.1.76.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[bundleFile:4.1.76.Final]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]

Once this event happens, NETCONF session cannot be established because the promise cannot be set to 'SUCCESS' even if all the negotiation has been completed successfully:

2022-10-13T21:48:43,976 | WARN  | globalWorkerGroup-3-2 | AbstractNetconfSessionNegotiator | 258 - org.opendaylight.netconf.netty-util - 4.0.3.SNAPSHOT | An exception occurred during negotiation with null on channel [id: 0x738232cc]
java.lang.IllegalStateException: complete already: NetconfSessionPromise@37c85c76(failure: java.lang.IllegalStateException: Channel closed)
	at io.netty.util.concurrent.DefaultPromise.setFailure(DefaultPromise.java:112) ~[bundleFile:4.1.76.Final]
	at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.negotiationFailed(AbstractNetconfSessionNegotiator.java:330) ~[bundleFile:?]
	at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.channelRead(AbstractNetconfSessionNegotiator.java:370) ~[bundleFile:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[bundleFile:4.1.76.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327) ~[bundleFile:4.1.76.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[bundleFile:4.1.76.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327) ~[bundleFile:4.1.76.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:61) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:370) ~[bundleFile:4.1.76.Final]
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) ~[bundleFile:4.1.76.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503) ~[bundleFile:4.1.76.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) ~[bundleFile:4.1.76.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[bundleFile:4.1.76.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[bundleFile:4.1.76.Final]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.IllegalStateException: complete already: NetconfSessionPromise@37c85c76(failure: java.lang.IllegalStateException: Channel closed)
	at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:99) ~[bundleFile:4.1.76.Final]
	at org.opendaylight.netconf.nettyutil.NetconfSessionPromise.setSuccess(NetconfSessionPromise.java:88) ~[bundleFile:?]
	at org.opendaylight.netconf.nettyutil.NetconfSessionPromise.setSuccess(NetconfSessionPromise.java:26) ~[bundleFile:?]
	at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.negotiationSuccessful(AbstractNetconfSessionNegotiator.java:324) ~[bundleFile:?]
	at org.opendaylight.netconf.client.NetconfClientSessionNegotiator.handleMessage(NetconfClientSessionNegotiator.java:88) ~[bundleFile:?]
	at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.channelRead(AbstractNetconfSessionNegotiator.java:367) ~[bundleFile:?]
	... 20 more


 Comments   
Comment by Sangwook Ha [ 14/Oct/22 ]

So something like this would work: https://git.opendaylight.org/gerrit/c/netconf/+/102590
But I'm not sure why session negotiation failure due to timeout requires a special treatment where promise is not failed, so negotiation is retried with the same promise. It seems to be just one of the failure scenarios - since timer does not start until channel becomes active, it does not cover pure reachability issue different from other exceptions.

Comment by Robert Varga [ 14/Oct/22 ]

Yeah, but that patch seems to have other issues. Gawking at the stack trace, it seems a tad strange: the channel was closed before channelActive() was invoked?!

Can you post logs with AsyncSshHandler at debug, please?

I wonder whether AsyncSshHandler.handleSshChanelOpened() is executing outside the event loop and we end up somehow circling to AsyncSshHandler.safelyDisconnect() before channelActive() is processed...

Comment by Sangwook Ha [ 14/Oct/22 ]

Post karaf log at the DEBUG level. The error was triggered when device configuration was reapplied a few times forcing controller to establish new NETCONF connections while interrupting the negotiation process at breakpoints set in AbstractNetconfSessionNegotiator (channelActive, channelRead).

Comment by Sangwook Ha [ 14/Oct/22 ]

Looks like the device initiated disconnection probably because of the long idle time before it receives hello back:

2022-10-14T21:20:14,016 | DEBUG | globalWorkerGroup-3-5 | AbstractNetconfSessionNegotiator | 258 - org.opendaylight.netconf.netty-util - 4.0.3.SNAPSHOT | Starting session negotiation on channel [id: 0x1d4d427c]
2022-10-14T21:20:40,839 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-6 | NettyAwareChannelSubsystem       | 265 - org.opendaylight.netconf.shaded-sshd - 4.0.3.SNAPSHOT | handleEof(NettyAwareChannelSubsystem[id=0, recipient=43]-NetconfClientSessionImpl[netconf@/10.100.18.43:830][netconf]) SSH_MSG_CHANNEL_EOF
2022-10-14T21:20:40,840 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-6 | NettyAwareChannelSubsystem       | 265 - org.opendaylight.netconf.shaded-sshd - 4.0.3.SNAPSHOT | handleClose(NettyAwareChannelSubsystem[id=0, recipient=43]-NetconfClientSessionImpl[netconf@/10.100.18.43:830][netconf]) SSH_MSG_CHANNEL_CLOSE
2022-10-14T21:20:40,840 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-6 | NettyAwareChannelSubsystem       | 265 - org.opendaylight.netconf.shaded-sshd - 4.0.3.SNAPSHOT | handleClose(NettyAwareChannelSubsystem[id=0, recipient=43]-NetconfClientSessionImpl[netconf@/10.100.18.43:830][netconf]) prevent sending EOF
2022-10-14T21:20:40,840 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-6 | NettyAwareChannelSubsystem       | 265 - org.opendaylight.netconf.shaded-sshd - 4.0.3.SNAPSHOT | close(NettyAwareChannelSubsystem[id=0, recipient=43]-NetconfClientSessionImpl[netconf@/10.100.18.43:830][netconf]) Closing gracefully
2022-10-14T21:20:40,841 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-6 | Window                           | 265 - org.opendaylight.netconf.shaded-sshd - 4.0.3.SNAPSHOT | Closing Window[client/local](NettyAwareChannelSubsystem[id=0, recipient=43]-NetconfClientSessionImpl[netconf@/10.100.18.43:830][netconf])
2022-10-14T21:20:40,841 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-6 | Window                           | 265 - org.opendaylight.netconf.shaded-sshd - 4.0.3.SNAPSHOT | Closing Window[client/remote](NettyAwareChannelSubsystem[id=0, recipient=43]-NetconfClientSessionImpl[netconf@/10.100.18.43:830][netconf])
2022-10-14T21:20:40,842 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-6 | ChannelSession$1                 | 265 - org.opendaylight.netconf.shaded-sshd - 4.0.3.SNAPSHOT | close([NettyAwareChannelSubsystem[id=0, recipient=43]-NetconfClientSessionImpl[netconf@/10.100.18.43:830][netconf]] cmd=SSH_MSG_CHANNEL_DATA) Closing gracefully
2022-10-14T21:20:40,842 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-6 | NettyAwareChannelSubsystem       | 265 - org.opendaylight.netconf.shaded-sshd - 4.0.3.SNAPSHOT | sendEof(NettyAwareChannelSubsystem[id=0, recipient=43]-NetconfClientSessionImpl[netconf@/10.100.18.43:830][netconf]) already sent (state=Graceful)
2022-10-14T21:20:40,842 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-6 | ChannelSession$1                 | 265 - org.opendaylight.netconf.shaded-sshd - 4.0.3.SNAPSHOT | close([NettyAwareChannelSubsystem[id=0, recipient=43]-NetconfClientSessionImpl[netconf@/10.100.18.43:830][netconf]] cmd=SSH_MSG_CHANNEL_DATA][Graceful] - operationComplete() closed
2022-10-14T21:20:40,842 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-6 | ChannelAsyncInputStream          | 265 - org.opendaylight.netconf.shaded-sshd - 4.0.3.SNAPSHOT | close(ChannelAsyncInputStream[NettyAwareChannelSubsystem[id=0, recipient=43]-NetconfClientSessionImpl[netconf@/10.100.18.43:830][netconf]]) Closing gracefully
2022-10-14T21:20:44,837 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-6 | ChannelAsyncInputStream          | 265 - org.opendaylight.netconf.shaded-sshd - 4.0.3.SNAPSHOT | close(ChannelAsyncInputStream[NettyAwareChannelSubsystem[id=0, recipient=43]-NetconfClientSessionImpl[netconf@/10.100.18.43:830][netconf]]][Graceful] - operationComplete() closed
2022-10-14T21:20:44,838 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-6 | ChannelAsyncInputStream          | 265 - org.opendaylight.netconf.shaded-sshd - 4.0.3.SNAPSHOT | close(ChannelAsyncInputStream[NettyAwareChannelSubsystem[id=0, recipient=43]-NetconfClientSessionImpl[netconf@/10.100.18.43:830][netconf]]) Closing gracefully
2022-10-14T21:20:44,838 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-6 | ChannelAsyncInputStream          | 265 - org.opendaylight.netconf.shaded-sshd - 4.0.3.SNAPSHOT | close(ChannelAsyncInputStream[NettyAwareChannelSubsystem[id=0, recipient=43]-NetconfClientSessionImpl[netconf@/10.100.18.43:830][netconf]]][Graceful] - operationComplete() closed
Comment by Robert Varga [ 17/Oct/22 ]

Okay so we have some inter-thread handover:

2022-10-14T21:19:38,167 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-2 | AsyncSshHandler                  | 258 - org.opendaylight.netconf.netty-util - 4.0.3.SNAPSHOT | SSH session authenticated on channel: [id: 0x1d4d427c], server version: SSH-2.0-libssh_0.9.5
[...]
2022-10-14T21:20:14,013 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-5 | NettyAwareChannelSubsystem       | 265 - org.opendaylight.netconf.shaded-sshd - 4.0.3.SNAPSHOT | handleData(NettyAwareChannelSubsystem[id=0, recipient=43]- NetconfClientSessionImpl[netconf@/10.100.18.43:830][netconf]) SSH_MSG_CHANNEL_DATA len=6
2022-10-14T21:20:14,016 | DEBUG | globalWorkerGroup-3-5 | AbstractNetconfSessionNegotiator | 258 - org.opendaylight.netconf.netty-util - 4.0.3.SNAPSHOT | Starting session negotiation on channel [id: 0x1d4d427c] 

and then:

2022-10-14T21:20:46,512 | DEBUG | sshd-NetconfSshClient[a8b2d7e]-nio2-thread-6 | AsyncSshHandler                  | 258 - org.opendaylight.netconf.netty-util - 4.0.3.SNAPSHOT | SSH session closed on channel: [id: 0x1d4d427c]
[...]
2022-10-14T21:20:51,595 | DEBUG | globalWorkerGroup-3-5 | AbstractNetconfSessionNegotiator | 258 - org.opendaylight.netconf.netty-util - 4.0.3.SNAPSHOT | Session negotiation started with hello message <hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <capabilities>
        <capability>urn:ietf:params:netconf:capability:exi:1.0</capability>
        <capability>urn:ietf:params:netconf:base:1.1</capability>
        <capability>urn:ietf:params:netconf:base:1.0</capability>
    </capabilities>
</hello>
 on channel [id: 0x1d4d427c]
[...]
2022-10-14T21:21:10,178 | INFO  | globalWorkerGroup-3-5 | AbstractNetconfSessionNegotiator | 258 - org.opendaylight.netconf.netty-util - 4.0.3.SNAPSHOT | Failed to send message <hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <capabilities>
        <capability>urn:ietf:params:netconf:capability:exi:1.0</capability>
        <capability>urn:ietf:params:netconf:base:1.1</capability>
        <capability>urn:ietf:params:netconf:base:1.0</capability>
    </capabilities>
</hello>
 on channel [id: 0x1d4d427c]
java.lang.IllegalStateException: Channel closed
        at org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandlerWriter.write(AsyncSshHandlerWriter.java:59) ~[bundleFile:?]

note how we have things executing on sshd-nio2 threads and on globalWorkerGroup threads.

Also, there is a 30 second delay in negotiation start – but note also that "Session negotiation started" is triggered after the channel is closed – pointing towards a problem in state checking. I think we need to handle the case where channelActive is triggered and there is also a channelInactive is staged in the executor,

Comment by Robert Varga [ 17/Oct/22 ]

The interesting thing is the delay of 37,579 seconds between "starting" and "started" messages on the global worker thread. It is during this delay that the session goes down. This seems to indicate that AbstractNetconfSessionNegotiator.start() needs to check whether the channel is still open before embarking on sending the message.

We also need to figure out how AsyncSshHandler.safelyDisconnect() -> AsyncSshHandlerWriter.close() -> channel.close() is synchronized w.r.t. the the negotiator.

Comment by Robert Varga [ 18/Oct/22 ]

Rather than mucking around with lifecycle and trying to synchronize things, the fix is to run the two methods interacting with channel lifecycle on the corresponding executor – thus providing natural sequencing.

Comment by Sangwook Ha [ 18/Oct/22 ]

karaf-netconf-905.log: karaf log for https://git.opendaylight.org/gerrit/c/netconf/+/102740/

Comment by Robert Varga [ 18/Oct/22 ]

So here we are catching this transition:

java.lang.IllegalStateException: Channel closed
	at org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandlerWriter.write(AsyncSshHandlerWriter.java:59) ~[bundleFile:?]
	at org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler.write(AsyncSshHandler.java:186) ~[bundleFile:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:709) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:792) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:702) ~[bundleFile:4.1.76.Final]
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:113) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:709) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:792) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:702) ~[bundleFile:4.1.76.Final]
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:113) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:790) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:758) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:808) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1025) ~[bundleFile:4.1.76.Final]
	at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:306) ~[bundleFile:4.1.76.Final]
	at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.sendMessage(AbstractNetconfSessionNegotiator.java:340) ~[bundleFile:?]
	at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.start(AbstractNetconfSessionNegotiator.java:150) ~[bundleFile:?]
	at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.startNegotiation(AbstractNetconfSessionNegotiator.java:131) ~[bundleFile:?]
	at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.channelActive(AbstractNetconfSessionNegotiator.java:355) ~[bundleFile:?]

and also this:

java.io.EOFException: Channel is being closed    at org.opendaylight.netconf.shaded.sshd.common.channel.AbstractChannel$2.<init>(AbstractChannel.java:782) ~[bundleFile:?]
    at org.opendaylight.netconf.shaded.sshd.common.channel.AbstractChannel.writePacket(AbstractChannel.java:780) ~[bundleFile:?]
    at org.opendaylight.netconf.shaded.sshd.common.channel.throttle.DefaultChannelStreamWriter.writeData(DefaultChannelStreamWriter.java:46) ~[bundleFile:?]
    at org.opendaylight.netconf.shaded.sshd.common.channel.ChannelAsyncOutputStream.doWriteIfPossible(ChannelAsyncOutputStream.java:209) ~[bundleFile:?]
    at org.opendaylight.netconf.shaded.sshd.common.channel.ChannelAsyncOutputStream.writeBuffer(ChannelAsyncOutputStream.java:106) ~[bundleFile:?]
    at org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandlerWriter.writeWithPendingDetection(AsyncSshHandlerWriter.java:95) ~[bundleFile:?]
    at org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandlerWriter.write(AsyncSshHandlerWriter.java:78) ~[bundleFile:?]
    at org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler.write(AsyncSshHandler.java:125) ~[bundleFile:?]
    at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717) ~[bundleFile:4.1.76.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:709) ~[bundleFile:4.1.76.Final]
    at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:792) ~[bundleFile:4.1.76.Final]
    at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:702) ~[bundleFile:4.1.76.Final]
    at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:113) ~[bundleFile:4.1.76.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717) ~[bundleFile:4.1.76.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:709) ~[bundleFile:4.1.76.Final]
    at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:792) ~[bundleFile:4.1.76.Final]
    at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:702) ~[bundleFile:4.1.76.Final]
    at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:113) ~[bundleFile:4.1.76.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717) ~[bundleFile:4.1.76.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764) ~[bundleFile:4.1.76.Final]
    at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:790) ~[bundleFile:4.1.76.Final]
    at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:758) ~[bundleFile:4.1.76.Final]
    at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:808) ~[bundleFile:4.1.76.Final]
    at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1025) ~[bundleFile:4.1.76.Final]
    at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:306) ~[bundleFile:4.1.76.Final]
    at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.sendMessage(AbstractNetconfSessionNegotiator.java:340) ~[bundleFile:?]
    at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.start(AbstractNetconfSessionNegotiator.java:150) ~[bundleFile:?]
    at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.startNegotiation(AbstractNetconfSessionNegotiator.java:131) ~[bundleFile:?]
    at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.channelActive(AbstractNetconfSessionNegotiator.java:355) ~[bundleFile:?]

Both of these are a failure to send initial hello message. Since these are in the Netty->SSHD direction, there simply are SSHD transitions we have not observed yet (as they are running concurrently with Netty) – a closed or closing channel may be one of those.

If this ever happens it is equivalent to the session never being established, as the failure occurred when attempting IDLE->OPEN_WAIT transition and hence the transition becomes IDLE->FAILED instead.

Comment by Sangwook Ha [ 18/Oct/22 ]
--- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java
+++ b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java
@@ -327,6 +327,9 @@ public abstract class AbstractNetconfSessionNegotiator<S extends AbstractNetconf
         if (state == State.OPEN_WAIT && newState == State.ESTABLISHED) {
             return true;
         }
+        if (state == State.IDLE && newState == State.FAILED) {
+            return true;
+        }
         if (state == State.OPEN_WAIT && newState == State.FAILED) {
             return true;
         }
Generated at Wed Feb 07 20:16:12 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.