¿ªÔÆÌåÓý

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

Re: Autorestart issue


 

Thanks for giving this some thoughts Richard.

Based on your questions, I'm going to try three experiments. Please let me know if you have ideas on what else I should try.

1. This week I'm running only instance 1, directly (without IBC).?
I can already confirm that the issue?with the API log aborting (TWS log was always fine) is still occurring. So this part clearly has nothing to do with IBC, or with running multiple instances of TWS. I already have a ticket with IB about this. Sure enough, they tried to blame it on IBC, but that has now been debunked.
So far TWS restarted twice (Sunday & Monday) without issues.

2. Assuming the restarts run fine all week, next week I will run only instance 1 still, but this time *with* IBC.

3. The week after that I will run both instances without IBC.

And to answer your questions (in case this might trigger some additional ideas):

1. Yes, both instances are in live mode, and instance 2 really doesn't use 2FA (it uses an account domiciled in a jurisdiction that doesn't require 2FA).

2. Both instances are running TWS 10.19.2a?

3. There are no scheduled tasks to run IBC. If there were no restart issues I would just start IBC manually once a week on Sundays.

4. I never renamed tws1.exe to tws.exe. I do notice just now (while I'm not using IBC) that in Jts/1019 there is a tws1.exe dated 2022-11-15 (file version 1.19.1.7), while tws.exe is dated 2023-06-13 9file version 1.19.2.1). Does that mean that when IBC restarts TWS it uses an older version of TWS? Is that suspicious? Should I delete tws1.exe??

5. Unfortunately I can't leave instance?1 running if it is in read-only?mode (especially instance 1),?as I need non read-only for trading. Perhaps I can try that with instance 2. Is there a way to tell by looking at TWS if it is in read-only?mode (other than submitting an order)?

6. I'm not usually around when TWS restarts, but I'll try to be around. Does IBC log all TWS windows that come up, even if it is not a window it is waiting for or even knows about?

Thanks
Jimmy


On Fri, Jun 30, 2023 at 6:58?AM Richard L King <rlking@...> wrote:

Well, I¡¯ve been puzzling over this for a couple of hours now, and I can¡¯t see that IBC is doing anything it shouldn¡¯t (or not doing something it should).

?

TWS, on the other hand, seems to be behaving badly.

?

First off there¡¯s the issue with the TWS error messages about writing to its logfile. That in itself is strange, but what¡¯s stranger is that it only affects instance 1. Perhaps both instances are trying to write to the same logfile? (Note that these lines end up in IBC¡¯s log because TWS presumably just writes them to stderr, as it¡¯s not managing to write to its Log4J logfile, and IBC always records anything written to stderr.)

?

Secondly I notice that both instances are configured to run in live mode rather than paper trading mode, and yet only instance 1 seems to invoke 2nd factor authentication. Does the instance 2 account perhaps do 2FA via other means than IBKR Mobile?

?

Next, as you say TWS sometimes seem to sail though the auto-restart time without doing it. There¡¯s nothing IBC can do about this: it doesn¡¯t even know whether or when TWS should auto-restart.

?

Then there¡¯s the couple of cases where there is an existing session. Perhaps you somehow started these manually and forgot about it? The only other way it can happen is at auto-restart if the TWS executable still has its original filename: on Windows this is tws.exe. The start scripts rename this to tws1.exe, otherwise when TWS auto-restarts it loads a new instance of tws.exe directly which then runs without IBC (and the IBC script itself also starts another one running under IBC).

?

Overall, I¡¯m not sure what to suggest here. I note that your configuration certainly looks as though there should be no interaction at all between the two instances, but it might help to just turn one off for the moment and see if the other one behaves itself.

?

And I think the following are worth considering:

?

  • Make sure you have the latest version of TWS 1019 installed, which is 10.19.2a
  • It wouldn¡¯t do any harm to upgrade to the latest IBC, ie 3.17.0 released a few days ago
  • If you use a Scheduled Task to periodically run IBC (for example to ensure it¡¯s restarted after unexpected exit), make sure the task is configured not to run if an existing instance is already running
  • Make sure you never rename tws1.exe back to tws.exe while IBC is running
  • See what happens if you leave an instance running after it fails to initiate auto-restart. Does it do it the next day? Does it keep running forever?
  • Check whether there are any modal dialogs displayed at auto-restart time. It¡¯s just possible that TWS would not honour auto-restart in this case (but I¡¯ve no idea whether that¡¯s actually true).

?

Finally you say that TWS appeared to be in ¡®read-only API¡¯ mode. If that¡¯s the case, then it¡¯s TWS misbehaving, not IBC. IBC can set this at startup, but only if ReadOnlyApi=yes in config.ini.

?

I hope something in all this helps¡­

?

Richard

?

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