Search code examples
scalaasynchronousfinagle

Finagle client handle onConnected event


I'm trying to build async client for some tcp service. Service requires handshake. When initial connection is established I can make handshake, but if connection fails and finagle reconnects i have no way to make handshake again. Is there a way to catch connected event? Thank You!


Solution

  • You can override the method prepareConnFactory in your codec. Basically each time finagle establishes a connection it will execute this method before putting the connection into the queue.

    We use this feature in the ThriftClientFramedCodec to verify that the server is compatible with our custom thrift protocol.