You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I have a system configured with 2 addresses. If the first one is not responding during launch of application it will not try second system and will eventually quit (because the init code waits up to 60 seconds for successful login or other meaningful response).
Expected behavior
System tries second address in 30 seconds.
system information:
OS: Linux
Java version: JDK21
QFJ Version: 3.0.1
Additional context
20260613-12:20:11: Session FIXT.1.1:xxx->yyy schedule is daily, 05:30:00-UTC - 17:30:00-UTC (daily, 07:30:00-CEST - 19:30:00-CEST)
20260613-12:20:11: Created session: FIXT.1.1:xxx->yyy
20260613-12:20:11: Configured socket addresses for session: [/127.0.0.1:10134, /127.0.0.1:10135]
20260613-12:20:11: MINA session created: local=/127.0.0.1:43448, class org.apache.mina.transport.socket.nio.NioSocketSession, remote=view-localhost/127.0.0.1:10134
20260613-12:20:11: Disconnecting: Encountered END_OF_STREAM
20260613-12:20:41: MINA session created: local=/127.0.0.1:56316, class org.apache.mina.transport.socket.nio.NioSocketSession, remote=view-localhost/127.0.0.1:10134
20260613-12:20:41: Disconnecting: Encountered END_OF_STREAM
I think it may be caused by no callbacks reaching me because Session.next has this code:
if (message == EventHandlingStrategy.END_OF_STREAM) {
disconnect(ENCOUNTERED_END_OF_STREAM, false);
return;
}
and disconnect has this code:
if (logonReceived || logonSent) {
try {
application.onLogout(sessionID);
so I'm never notified of this. But that doesn't explain why it only tries the first socket address again and again.
Disconnect is immediate, but there's no callback about this and in 30 seconds there's the next connection attempt, sadly again to first address. I think this is some special disconnect, maybe FW Reject. It's part of disaster recovery tests.
@chrjohn How similar is this to #402? I think the underlaying cause might the same or just the same failure.
The author of the other issue claims that the failover mechanism works for unresolved address which makes sense since quickfix.mina.initiator.IoSessionInitiator.ConnectTask#getNextSocketAddress could throw an IllegalArgumentException when hostname is null from the previous, unresolved attempt. This will skip quickfix.mina.initiator.IoSessionInitiator.ConnectTask#pollConnectFuture call.
Yeah, I do a full recycle of the client between days so they would already start from host 0. However my scenario is that it restarts from 0 in one lifecycle without any other commands. These two states should be somehow distinguished.
I guess some kind of alternative would be to create client with just one host and on specific events change the host in the configuration (rebuilding the client if that's required), but this seems too heavy. Maybe add a config switch allowing/disallowing this kind of round robin ignoring?
I guess some kind of alternative would be to create client with just one host and on specific events change the host in the configuration (rebuilding the client if that's required), but this seems too heavy. Maybe add a config switch allowing/disallowing this kind of round robin ignoring?
Config is probably not the best, because we will have 2 broken functionalities driven by a configuration.
We could write custom round robin mechanics, but this requires a bit of thinking and some changes to get it right so I would avoid it for the time being. Here is what I'm thinking.
Currently we use different String resasons for disconnect reasons. Add an additional flag indicating if session was disconnected by END_OF_STREAM (initially boolean, maybe enum later for more reasons if required). The flag is stored in the quickfix.Session state. When new connection is made we check the flag and decide when the index should advance and / or be reset.
The implication of this is that if a session failovers during the day to Host2 and then sessions is disconnect by EndTime and later connected again it will still connect to Host2, but I guess this is expected behavior...
It's not that round robin doesn't advance. It does advance but is later reset on reconnect, treated as fresh. Can manual connect be the only one resetting round robin index and the one called from repeat timer don't?
Let me know how you want to approach this. I can probably prototype something soon.
One thing to highlight is what morvael said and how it looks in the code is that connection attempts are made sequentially from host 1..n. When successful connection is made to any HostX, where 1<= x <= n, the next connect attempt will again start from Host1. This seems to be the current logic.
If we start fiddling this is going to change. This is also what blocks failover in #402. Looking at the log it seems that connection is made (MINA) + fix handshake. It will never failover in this case, because on successful connect resets the Host to 1.
Looking at the log it seems that connection is made (MINA) + fix handshake
As written in #402 , to me a successful FIX connection is the exchange of Logon messages, i.e. Logon sent and received. Otherwise it is no successful FIX connection.
I mentioned somewhere else that we should probably have some kind of interface/strategy if someone would like to tweak the failover behaviour. But maybe it is sufficient to change the logic to not treat a successful TCP connection as if it was a working FIX connection.
Activity
morvael commentedon Jun 13, 2026
Maybe the problem is with
IoSessionInitiator.pollConnectFuture()which always resetsnextSocketAddressIndexto 0? But this is just my wild guess.morvael commentedon Jun 13, 2026
This is the stacktrace where it set
nextSocketAddressIndexfrom 1 to 0 and attempted to reconnect to the same bad address:edit: sorry uploading images failed so here's link: https://ibb.co/VW2DLFBX
chrjohn commentedon Jun 13, 2026
I need to look at this after the weekend. Setting SocketConnectTimeout should help with the long delay though
morvael commentedon Jun 13, 2026
Disconnect is immediate, but there's no callback about this and in 30 seconds there's the next connection attempt, sadly again to first address. I think this is some special disconnect, maybe FW Reject. It's part of disaster recovery tests.
chrjohn commentedon Jun 13, 2026
StateListener.onDisconnect() should get called. Maybe also .onConnectException(), but probably not since I cannot see any exception in the log.
the-thing commentedon Jun 14, 2026
@chrjohn How similar is this to #402? I think the underlaying cause might the same or just the same failure.
The author of the other issue claims that the failover mechanism works for unresolved address which makes sense since
quickfix.mina.initiator.IoSessionInitiator.ConnectTask#getNextSocketAddresscould throw anIllegalArgumentExceptionwhen hostname is null from the previous, unresolved attempt. This will skipquickfix.mina.initiator.IoSessionInitiator.ConnectTask#pollConnectFuturecall.morvael might be onto something here.
chrjohn commentedon Jun 16, 2026
@the-thing looks like a similar issue to me. Any idea how we could detect the timeout?
the-thing commentedon Jun 17, 2026
I will have a look soon, but it seems like there are two things that we have to confirm.
quickfix.SessionStateListener#onDisconnectis getting called (I think it does)morvael commentedon Jun 17, 2026
I admit I'm maybe not using SessionStateListener, so only the round robin thing is a problem.
the-thing commentedon Jun 17, 2026
I think the timeout is already being detected.
the-thing commentedon Jun 17, 2026
This is probably the breaking change.
#152
morvael commentedon Jun 17, 2026
Yeah, I do a full recycle of the client between days so they would already start from host 0. However my scenario is that it restarts from 0 in one lifecycle without any other commands. These two states should be somehow distinguished.
morvael commentedon Jun 17, 2026
I guess some kind of alternative would be to create client with just one host and on specific events change the host in the configuration (rebuilding the client if that's required), but this seems too heavy. Maybe add a config switch allowing/disallowing this kind of round robin ignoring?
the-thing commentedon Jun 17, 2026
Config is probably not the best, because we will have 2 broken functionalities driven by a configuration.
@chrjohn @morvael
We could write custom round robin mechanics, but this requires a bit of thinking and some changes to get it right so I would avoid it for the time being. Here is what I'm thinking.
Currently we use different
Stringresasons for disconnect reasons. Add an additional flag indicating if session was disconnected byEND_OF_STREAM(initially boolean, maybe enum later for more reasons if required). The flag is stored in thequickfix.Sessionstate. When new connection is made we check the flag and decide when the index should advance and / or be reset.The implication of this is that if a session failovers during the day to Host2 and then sessions is disconnect by
EndTimeand later connected again it will still connect to Host2, but I guess this is expected behavior...morvael commentedon Jun 17, 2026
It's not that round robin doesn't advance. It does advance but is later reset on reconnect, treated as fresh. Can manual connect be the only one resetting round robin index and the one called from repeat timer don't?
the-thing commentedon Jun 17, 2026
That's what I meant. I rephrased.
the-thing commentedon Jun 17, 2026
@chrjohn
Let me know how you want to approach this. I can probably prototype something soon.
One thing to highlight is what morvael said and how it looks in the code is that connection attempts are made sequentially from host 1..n. When successful connection is made to any HostX, where 1<= x <= n, the next connect attempt will again start from Host1. This seems to be the current logic.
If we start fiddling this is going to change. This is also what blocks failover in #402. Looking at the log it seems that connection is made (MINA) + fix handshake. It will never failover in this case, because on successful connect resets the Host to 1.
chrjohn commentedon Jun 18, 2026
@the-thing
As written in #402 , to me a successful FIX connection is the exchange of Logon messages, i.e. Logon sent and received. Otherwise it is no successful FIX connection.
I mentioned somewhere else that we should probably have some kind of interface/strategy if someone would like to tweak the failover behaviour. But maybe it is sufficient to change the logic to not treat a successful TCP connection as if it was a working FIX connection.