Keyboard Shortcuts
Likes
Search
IB Gateway auto-restart fails - "COMPETE: session kicked out" and "Disconnect all farms due to competing session [control=false,context=]."
Hi,
My first post here and I hope I'm posting in the right way and place.
Context: - I have a Docker container running an instance of the Interactive Brokers Gateway, paper trading account, on a remote Linux server - The IB Gateway is set to auto-restart every day at 8:30 AM GMT - I use Xvfb, a virtual display, so I have no physical graphic interface whilst running
- I am currently solely testing the daily auto-restart, thus the app has no clients connected and no requests whatsoever submitted
My problem is that so far, it never made it to a second restart: I may start the container today, that will successfully (reading the logs and experiencing the "another session is running..." warnings both on my phone or local instance of IB Gateway/TWS) launch and run IB Gateway, it will make it to the following day restart and succede (judging again from logs and trying to login from somewhere else); however, the second day auto-restart always fails. Worth to clarify that the failing restart is not on a Saturday/Sunday, which I'm aware is expected to require authentication again. What I can see in the launcher.log of a succesfull restart as opposed to the one of the failing restart is that the latter, at some point after the message ?
"SPLASH Authenticating"
?
reads
?
"COMPETE: session kicked out"
?
and few milliseconds after
?
"Disconnect all farms due to competing session [control=false,context=]."
?
and then after a few (just number after SPLASH ending differently)
"SPLASH 20001 step 2 AuthDispatcher.processDataItr" "Received NS_TEST_REQUEST"
....
?
i get a
?
"Socket for connection cdc1.ibllc.com:4001 (SSL) was closed by peer."
"Listener thread terminating [sessionID=2] [seen=399,totalShifted=399,moreAvailable=0]"
"Disconnecting cdc1.ibllc.com:4001 (SSL) [disconnectDetails=DisconnectDetails[sessionID=2,endPoint=cdc1.ibllc.com:4001 (SSL),reason=DISCONNECT_ON_BROKEN_SOCKET,cause=null,systemMessage=recv: EOF,keepSocketOpen=false]]..." "Socket closed." then
?
"SPLASH Attempt 1: server error, will retry in seconds"
?
And after this the whole log, for hours will repeat everything again and again with just increasing the attempt number in the following message
?
"SPLASH Attempt 2: connecting to server"
In a successful restart log, right after the first message listed above, things would have taken a different fold, the authentication would succede, and some routing tasks before rotating to the operational log would be printed. To be frank, I do have a X server option when for when I test locally on my machine where I built the Doicker image, but I never tested?for days the behaviour to see what might pop up. I did test few restarts in a row by just changing the restart time on the go, and they all succeded, but I understand many things change between the two setups, so this might be of little help. Anyone care to help with what's going on here? I surely can provide the logs if needed. Thank you,
Renato? ? |
You can have only one session at a time for each user/password combination. When there are simultaneous logins from IBGW on Linux and your phone, only one of the two can own the session and the other is disconnected from IBKR. It sounds like from your description, IBGW on Linux does not own the session when it is time for restart. Not owning the session, IBGW will not be able to restart. To assure proper IBGW operation on Linux, do not log into the same account from your phone (or Client Portal or Web Trader). For live accounts, you can create additional user accounts so that IBGW and your phone use two different sessions. But even in that setup you need to make sure that the phone does not take the market data subscriptions from IBGW. Alternatively you can purchase separate market data subscriptions for the secondary user account on the phone. ´³¨¹°ù²µ±ð²Ô ?
On Sat, Mar 15, 2025 at 09:52 AM, Renato Votto wrote:
|
Thank you ´³¨¹°ù²µ±ð²Ô,
This is weird though: that only time I tried to login from the phone in paper account to test whether the Linux instance was still logged in after the restart, I always refused to continue with the login from the phone (as the warning itself was the only proof I was looking for). Then I struggle to undersant how 20+ hours later, at the time of the second daily restart, the phone app owns a session. Also, on the second day, when I try again to login from the phone to see whether the Linux instance restarted and logged in correctly, I have to enter both credentials from scratch.
?
This gave me a hint though, I'll test the container locally with UI on the X server and attempt a login from the phone or my local IB installation before running an auto-restart and see if any unepected windows pop up or different behaviour. Also, in my initial post I forgot to mention that, speaking of display windows, by printing out the the current windows from the Xvfb virtual display during the "limbo" state of the endless SPLASH attempts, I noticed that some re-login related window was on (but I have never been able to replicate this with physical UI): Window ID: 0x400e3d _NET_WM_NAME(UTF8_STRING) = "Re-login is required" WM_NAME(STRING) = "Re-login is required" Window ID: 0x400e48 _NET_WM_NAME(UTF8_STRING) = "FocusProxy" WM_NAME(STRING) = "FocusProxy" Window ID: 0x400e45 _NET_WM_NAME(UTF8_STRING) = "Content window" WM_NAME(STRING) = "Content window" Window ID: 0x400e44 _NET_WM_NAME(UTF8_STRING) = "sun-awt-X11-XIconWindow" WM_NAME(STRING) = "sun-awt-X11-XIconWindow" Window ID: 0x40002a _NET_WM_NAME(UTF8_STRING) = "Attempt 160: Authenticating..." WM_NAME(STRING) = "Attempt 160: Authenticating..." Window ID: 0x400035 _NET_WM_NAME(UTF8_STRING) = "FocusProxy" WM_NAME(STRING) = "FocusProxy" Window ID: 0x400032 _NET_WM_NAME(UTF8_STRING) = "Content window" WM_NAME(STRING) = "Content window" Window ID: 0x400009 _NET_WM_NAME(UTF8_STRING) = "IBKR Gateway" WM_NAME(STRING) = "IBKR Gateway" Window ID: 0x400023 _NET_WM_NAME(UTF8_STRING) = "FocusProxy" WM_NAME(STRING) = "FocusProxy" Window ID: 0x400020 _NET_WM_NAME(UTF8_STRING) = "Content window" WM_NAME(STRING) = "Content window" Window ID: 0x40003a _NET_WM_NAME(UTF8_STRING) = "Loading..." WM_NAME(STRING) = "Loading..." Window ID: 0x400045 _NET_WM_NAME(UTF8_STRING) = "FocusProxy" WM_NAME(STRING) = "FocusProxy" Window ID: 0x400042 _NET_WM_NAME(UTF8_STRING) = "Content window" WM_NAME(STRING) = "Content window" Window ID: 0x400041 _NET_WM_NAME(UTF8_STRING) = "sun-awt-X11-XIconWindow" WM_NAME(STRING) = "sun-awt-X11-XIconWindow" Window ID: 0x400031 _NET_WM_NAME(UTF8_STRING) = "sun-awt-X11-XIconWindow" WM_NAME(STRING) = "sun-awt-X11-XIconWindow" Window ID: 0x40001f _NET_WM_NAME(UTF8_STRING) = "sun-awt-X11-XIconWindow" WM_NAME(STRING) = "sun-awt-X11-XIconWindow" Window ID: 0x40000a _NET_WM_NAME(UTF8_STRING) = "install4j-ibgateway-GWClient" WM_NAME(STRING) = "install4j-ibgateway-GWClient" Window ID: 0x600002 ? Thank you for your help, much appreciated. If I cannot come up with a solution shortly, I'll give up and just go with IBC. Though I liked the portable container implementation, the minimal settings and the only need to delegate to a cron task for the weekly re-authentication. By the way, here's the container source, if anyone wants to play with it (originally forked by Ryan Clouser similar concept): ? Renato |
Hard to say what is going on, Renato. While IBGW does not implement fancy forms and complex media content (compared to TWS), it still needs a complete and pretty sophisticated graphics subsystem for JavaFX 2.0 to work properly. And mot likely a window manager as well. I have been using Xtigervnc with Xfce4 on Ubuntu for years and it works great. But I don't use Docker containers. And you might want to get this working manually before you start IBGW with IBC since IBC will not be able to help you if the root cause relates to the graphics subsystem or X11 window management. ´³¨¹°ù²µ±ð²Ô ? ? On Sat, Mar 15, 2025 at 12:07 PM, Renato Votto wrote:
|
Ok, here's a (hopefully) good development: I just casually let a container displaying on the X server run on my local machine, went away, the machine went in standby and:
?
Excatly the same log messages and apparently the same window popping up!
So it all seems due to a lost internet connection and having to confirm a re-login request..
I wonder what's the equivalent of the standby causing the disconnection on my local machine is on the remote server, but that can easily be found out,a nd I have a problem to solve now.
If this is now sorted, I hope it'll be useful for someone ending up in the same trap. Thank you ´³¨¹°ù²µ±ð²Ô for the quick help.
?
Renato |
I would be a little careful with tests over the weekend, especially Saturdays. That is when IBKR does the "oil changes" on their servers and specifically logins and restarts may not work as expected. That is particularly true, when TWS or IBGW how a white box with "IMPORTANT: Due to scheduled maintenance clients may be unable to connect through our web, mobile, and desktop trading platforms." as it does right now for me. ´³¨¹°ù²µ±ð²Ô ? ?
On Sat, Mar 15, 2025 at 01:38 PM, Renato Votto wrote:
|
¿ªÔÆÌåÓýI had a similar issue with IBC+IBGW+my trading app running in a Docker container. I used a cron job to shutdown the container after market close each day and then restart it before market open. Starting on Sunday with a full user login (with 2FA via IB
Key) it restarts ?fine one or two times but then fails around mid-week and I¡¯m not able anymore to start up until the following Sunday (when IBGW requires a full login again via IBC). Not even when just running IBGW+my app on local Mac (not Dockerized) using
the same user login.?
?The error message was also along the lines that that ¡°duplicate client IDs were running¡±. I believe I hard coded client ID 0 so it receives orders from all clients (also from TWS running on an alternate user login).?
I never looked further into the root cause of this but ?I suspect it may be because of a shutdown of the docker container that leaves some client connection active, maybe between IBGW and IB backend as it survives even the IBGW shutdown or running in a
different environment (local vs Dockerized).?
rgds, Bart On Mar 15, 2025 at 10:28?AM -0700, ´³¨¹°ù²µ±ð²Ô Reinold via groups.io <TwsApiOnGroupsIo@...>, wrote:
|
Yeah, that is true.
?
In fact I tried to manually just disconnect internet only, and upon reconnection the session was re-established fully without the re-login step, so it's not deterministically true what I highlighted above.
So the case they require you to re-login could also depend on their server decision after a disconnection.
?
You know guys, probably the best thing is just a cron job that every now and then checks the app health and in case restarts the container. With the paper account is autonomous, with the live it means when it happens you need to go through 2FA.
?
Renato |