IbcAlpha / IBC

Automation of Interactive Brokers TWS. You can download the latest release here: https://github.com/ibcalpha/ibc/releases/latest
GNU General Public License v3.0
1.03k stars 180 forks source link

Weekly auto-restart doesn't work properly #205

Closed akatsev1956 closed 1 year ago

akatsev1956 commented 1 year ago

After weekly restart (Saturday night, at 2023.04.09 between 05:47 and 05:55 UTC) my IB API app receives error 502. When I shut down IBC and start it again manually everything works properly. IBC-3.15.2_GATEWAY-1019_SATURDAY.txt IBC-3.15.2_TWS-1019_FRIDAY.txt IBC-3.15.2_GATEWAY-1019_FRIDAY.txt IBC-3.15.2_GATEWAY-1019_SUNDAY.txt

rlktradewright commented 1 year ago

The log files show that autorestart is working perfectly.

In fact there in only one autorestart shown in the files commencing at 2023-04-07 23:59:00:742, not between 05:47 and 05:55 UTC as you stated.

And what do you mean by 'weekly restart': it restarts every day.

In any case, IBC is not involved in any way in API client program connections. I suggest you check out your API settings and make sure your program is using the correct server address, port, and client id.

akatsev1956 commented 1 year ago

First of all, thank you very much!

The issue is that I found my app not running Sun morning. So I assumed there was famous weekly shut down of IBGateway around midnight between Sat an Sun, and IBC couldn’t survive it… I dare say my settings are right, because manual restart worked properly without any change in the settings. So, I still don’t understand what has happen there...

Again, thanks a lot, Sincerely, Aryeh Katsev.

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows

rlktradewright commented 1 year ago

You seem to have a fundamental misunderstanding about something.

Both TWS and Gateway require to be restarted every day. There are two settings in the 'Lock and Exit' section of the configuration dialog that control this:

Now whenever a TWS/Gateway instance shuts down, any API program that is currently connected loses its connection, so you get a 502 error. This is true whether you use AutoLogoff or AutoRestart. It is absolutely your responsibility to make the application connect to the API again. IBC cannot help with this.

akatsev1956 commented 1 year ago

Thank you very much for the comprehensive explanation it sounds much more clear than all the stuff I saw before. Am I right, that error 502 I’ll receive only when I try to connect(), otherwise I shall receive error 504?

Thank you in advance,

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows

rlktradewright commented 1 year ago

[Please, when you respond to a GitHub issue, either do it directly on the repository itself (using the 'view it on GitHub' link), or if you must use email, don't quote the post you're responding to. It's pointless having the whole of my last post repeated in your response. Can you please edit your last two posts to remove the quoted stuff.]

I don't know the answer to your 502/504 question, because i don't use IB's API implementation: I have my own version.

This is the sort of thing you should just discover for yourself, by experimentation, or reading the documentation, or asking on the IBAP User Group at https://groups.io/g/twsapi.

akatsev1956 commented 1 year ago

Thank you!

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows

tredondo commented 1 year ago

@akatsev1956 Please re-read part where you were asked to remove the quoted stuff. It annoys others as well :)