Solution to keep IB Gateway alive?

Discussion in 'Interactive Brokers' started by thecalip, Apr 5, 2020.

  1. Is anyone with issue with IB Gateway stay connected? It used to be able to connect forever but not any more.

    Tried both stables and latest version but both has issue. The stable version just disconnect you. The last version restart once a day but always on Sunday or 7 days, that it cannot reconnect after restart.

    Anyone with any solution or where I can download an older version that works?

    Thanks,
    C
     
  2. FrankInLa

    FrankInLa

    It does again, even tws autoreconnects (I use the newest version) without any human intervention. Have seen it now for several weeks. Each day the logout window pops up once but after the timeout tws reloads itself (and gateway as well when I checked for 3 days in a row) without any human intervention.

     
  3. ValeryN

    ValeryN

    There is no way around the restart it as far as I know. But there are ways to make it automated and reduce to about a minute outage at a scheduled time of your convenience. Let's say 15 mins after the market close.

    The way below is a bit complicated and might take you a week or two to get working, depending on experience with containers, but it's fairly stable. Mine runs this way with approx one failure on a startup per month.

    I package ib-gateway inside of Docker container and bundle with IBCAlpha/IBC wrapper, which handles a few common "user interactions" IB GW might wanna have time to time. This is just one example how to do this. I wouldn't recommend using pre-packaged IB or IBC images for security reasons - https://github.com/paulrosinger/ibc-docker

    Once you have a docker image, ideally deploy into either Kubernetes or if wanna keep things simple via docker-compose with autoheal container running alongside. Here is a health check you can use to detect when IB shutdown, autoheal or Kubernetes will keep calling it to determine if a restart is needed.

    Code:
        healthcheck:
          test: ["CMD-SHELL", "pgrep java && exit 0"]
          interval: 5s
          timeout: 3s
          retries: 4
    
    Good luck.

    Val
     
  4. FrankInLa

    FrankInLa

    The restart happens, true. But you don't need any coding or other apps to make it restart itself. Check out the new version.

     
  5. This is a feature which is built-in on purpose by IB. They want to ensure that users provide their credentials at least once per week. Which is why they disconnect the connection to Gateway on Saturday and the user needs to re-login. This feature is present from Gateway version 974 onwards.
     
  6. FrankInLa

    FrankInLa

    True but not during the week, at least not on the newest version on which I am running.

     
  7. I don't mind the restart. I set it at 5:30 PM when Globex is closed. The issue is it failed after a week or so. Looking a the log, it looks like my security token expired. I have attached the log.

    Hope there is a solution to this. It would be bad if I have to monitor this or force myself to remember to sign in every week.
     
    • ib.txt
      File size:
      10 KB
      Views:
      42
  8. ValeryN

    ValeryN

    Thanks, will have a look.

    Though containers are worth considering for generic fault tolerance and auto-healing features, regardless of IB provided features. But it is certainly a whole different level of complexity.

    Val
     
  9. FrankInLa

    FrankInLa

    Agreed. I wrote a small script that checks on the gateway connectivity both locally and between gateway and IB servers and sends a notification to me via pushover upon disconnects.

     
  10. d08

    d08

    Auto-shut down every day and restart with IBCAlpha. Works perfectly fine.
     
    #10     Apr 6, 2020