Skip to main content

Netty

Implementing Automatic Reconnection for Netty Client

One of the first requirement of Netty ISO8588 client connector was the support for automatic reconnect.

One of the first receipts I came across was Thomas Termin’s one. He suggests adding a ChannelHandler which will schedule the calling of client’s connect() method once a Channel becomes inactive. Plus adding ChannelFutureListener which will re-create a bootstrap and re-connect if initial connection was failed.

Although this is a working solution, I had a feeling that something is not optimal. Namely, the new Bootstrap is being created on every connection attempt.

So, I created a FutureListener which should be registered once a Channel is closed.

Netty: How to Initiate SSL Handshake From Client

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 channelConnected(...). It works fine unless SslHandler is used in the pipeline. If handler is present, channelConnected() was never called on my handler.