¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Error - 2157


 

Building on Gordon's comments here some thoughts:
  • Gordon pointed you to the documentation and as you can see from the heading for the 2xxx codes, they are warnings and not real errors.
  • Some error message say something like "XYZ has become inactive". Those are the cases Gordon mentioned, where TWS/IBGW has disconnected a data farm that is currently not in use, but will transparently reconnect that farm as soon as you'd make a related request.
  • Some error messages say something like "XYZ is disconnected". Those are cases, such as your code 2157, where TWS/IBGW connections got disconnected from the IBKR server that is mentioned in the error message. Shortly after that message you generally get an "all clear" message that indicates that the connection got reestablished.

Gordon is correct in that most of these "disconnect" events take place during the daily IBKR maintenance/reset window for your region and it takes only seconds (in fact often sub-seconds) for the "reconnected" message to come in. And if you have several accounts connected (such as a live and a paper trading account), each account will get the disconnect/reset at a different time within the daily reset window,

I suggest you do nothing special as long as your disconnects are brief and during the reset window. Restarting TWS/IBGW or your client will change nothing, will likely take much longer than the disconnect periods, and runs the risk of failing in case the connection is not back up yet. In case of 2157 you might just avoid making any requests that relate to instrument information (such as reqContractDetails, trading schedules, and similar) or be prepared to repeat the requests once the secdef farm is reconnected. But that should not be too hard, since you will likely make those calls when your client starts anyway.

The story changes considerably if your disconnects are for extended periods of time, outside the maintenance/reset window, several different 2xxx disconnects happen simultaneously, and you also get error 1100 as well. In those cases, look for a transient network issue between your TWS/IBGW and the IBKR infrastructure. Here a few situations that come to mind from real life experiences:
  • Your TWS/IBGW is connected to IBKR servers in a different region, data packets travel half around the world, and the natural higher packet loss rates causes brief outages. Just use the green "DATA" button in TWS/IBGW and check that they are connected locally.
  • Your firewall/internet security software might interfere with certain packets, ports, or protocols used by TWS/IBGW
  • A high packet loss rate or an unstable network hop between TWS/IBGW and IBKR may cause intermittent disconnects. If one of those legs is, for example, a Wifi connection, someone in your house with a craving for microwave popcorn might cause brief disconnects.
  • Any equipment between TWS/IBGW and IBKR might have to renew a DHCP lease (your server, routers, switches, Wifi access points, internet modems). Disruptions will take place even if the renewal is instantaneous and the equipment's IP address does not change.
  • Your ISP might reset/update the modem regularly and disconnect you entirely from the Internet during that time. Similarly, a piece of network equipment might get an automatic firmware or configuration update.

But chances are that your 2157 are brief during the reset window and you don;t have to do anything special.

Hope this helps,

´³¨¹°ù²µ±ð²Ô

Join [email protected] to automatically receive all group messages.