+ }
+
+ channel.pipeline().addLast(NAME_OF_EXCEPTION_HANDLER, new ExceptionHandlingInboundChannelHandler());
+
+ // Remove special outbound handler for hello message. Insert regular netconf xml message (en|de)coders.
+ replaceChannelHandler(channel, AbstractChannelInitializer.NETCONF_MESSAGE_ENCODER,
+ new NetconfMessageToXMLEncoder());
+
+ synchronized (this) {
+ lockedChangeState(State.OPEN_WAIT);
+
+ // Service the timeout on channel's eventloop, so that we do not get state transition problems
+ timeoutTask = timer.newTimeout(unused -> channel.eventLoop().execute(this::timeoutExpired),
+ connectionTimeoutMillis, TimeUnit.MILLISECONDS);
+ }
+
+ LOG.debug("Session negotiation started on channel {}", channel);
+
+ // State transition completed, now run any additional processing
+ helloFuture.addListener(this::onHelloWriteComplete);
+ }
+
+ private void onHelloWriteComplete(final Future<?> future) {
+ final var cause = future.cause();
+ if (cause != null) {
+ LOG.info("Failed to send message {} on channel {}", localHello, channel, cause);
+ negotiationFailed(cause);
+ } else {
+ LOG.trace("Message {} sent to socket on channel {}", localHello, channel);
+ }
+ }