Table of Contents
I have had spent some time recently making netty 3.6 sending some message when connection has been established.
What documentation suggests to do is to extend
SimpleChannelUpstreamHandler and override method
It works fine unless
SslHandler is used in the pipeline.
If handler is present,
channelConnected() was never called on my handler.
The problem was caused by client, which did not initialized SSL handshake on connection.
Until handshake completed, no other
ChannelHandlers are notified.
Hopefully, there is a convenient way to initiate handshake on the client. Netty documentation states:
false(default) you will need to take care of calling
handshake()by your own. In most situations were
SslHandleris used in ‘client mode’ you want to issue a handshake once the connection was established. if
setIssueHandshake(boolean)is set to
trueyou don’t need to worry about this as the SslHandler will take care of it. http://netty.io/3.6/api/org/jboss/netty/handler/ssl/SslHandler.html
So, you should set
SslHandler before establishing the connection:
SslHandler sslHandler = new SslHandler(engine); setIssueHandshake(true); pipeline.addLast("ssl", sslHandler);
After that, server got hadshaked and
SslHandler fired connected
ChannelStateEvent to other