Question

I'm trying to find a good way to detect a loss of connection.

My adapter is implemented as a Fix::Application based on one of the examples. It uses a socket initiator to connect to the fix gateway.

When I unplug the internet it takes about 30 seconds for the Fix::Application's onLogout method to be fired. It seems like some underlying class would be aware that there is a problem with the socket much earlier. Is there a quick way took hook into this?

Was it helpful?

Solution

The best way to solve this would probably be to decrease your Heartbeat Interval so you know sooner. I don't know of any messages that fire for a loss of TCP connection, but I don't think QuickFix is listening for OS events either. Although, it would likely flow through the fromAdmin event if there were such a message.

Did you post your question to the QuickFix DL?

OTHER TIPS

It's possible that the fix engine you're using doesn't call back when TCP is disconnected, or it calls back on something other than onLogout. Since you're using fix, I would guess it forces a logout due to missed heartbeats.

Quick way would be to look into the code and check where socket close is being handled, and what path executes when this happens.

TCP itself comes with a native heartbeat mechanism called SO_KEEPALIVE. Problem is that the default interval for this heartbeat can be as high as 2 hours. This is configured at the OS level. So in theory you can turn on SO_KEEPALIVE, configure a reasonable heartbeat interval at the OS level and be happy. However, because as said this is very OS dependent, most applications choose to implement heartbeating at the application level, and FIX is no exception. Decreasing your FIX heartbeat interval is the way to go here, especially if you are relying on cancel-on-disconnect and extra seconds of undetected connection loss can lead to unwanted order executions. A FIX gateway implemented on top of any fix engine should support heartbeating configuration out-of-the-box. Take a look on CoralGateway for an example. (Disclaimer: I am one of the developers of CoralGateway)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top