When I connect an initiator to a FIX server using SSL via the initiator.start() method, it fires up a separate thread to establish the connection. Now when this fails e.g. due to an SSL handshake issue or an issue with server connectivity, the error is thrown out to the logs but can’t seemingly be trapped in code and managed. How can I detect/trap when the error happens?

Disconnecting: Socket exception (<server ip>): java.net.SocketException: Connection reset.

At the bottom of the stack trace is the threadpool executor.

I have a try-catch around the start method but as the exception happens in another thread it can’t catch it.

2

You should implement the quickfix.SessionStateListener interface in your application.

The onDisconnect() callback should get called in your case.

By the way: the try-catch around your Initiator’s start() method will only catch Exceptions that occur during the startup process, e.g. configuration errors.

Update: starting from QuickFIX/J 2.3.0 you could also implement the callback onConnectException() from the SessionStateListener which will notify you of Exceptions that happen during the initialization of the connection in the Initiator.

6