开云体育

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

2FA prevents TWS restarts without human authorisation


 

Hi,

For the last 2 years, I have kept TWS consistently and constantly running through daily scheduled and every odd unscheduled restart with the need for any human intervention.

This is achieved through the help of IBC and Watchdog.

Unfortunately, with the recently mandated 2FA security measure, no restart can be completed without a human acknowledgement through the IB Key on my iPhone.

I have been searching for a remedy/workaround for weeks. The closest I have come across is to set the Lock and Exit behaviour in TWS to "Restart" instead of "Logoff", which did not improve things. It still requires the IB Key authorisation.

I would be immensely grateful if someone in the community could offer me tips/suggestions, including switching to IB Gateway if absolutely necessary to restore the convenience I used to have.

Thanks very much in advance!

I am running IBC 3.16.2+ and TWS from 10.19+ on both Linux and macOS platforms.

Chen


 

Hi Chen

I don't think there's a way round that with TWS. But it can be made reasonably painless with IBC and IB Gateway.

With Gateway you only get a forced restart over the weekend. I schedule my Gateway to shutdown early afternoon Saturday anyway and restart?early afternoon Sunday (UK time).
IBC has a really useful setting that will keep retrying if you miss the first 2FA request.

Andy
?




------ Original Message ------
Date 16/10/2023 16:40:26
Subject [ibc] 2FA prevents TWS restarts without human authorisation

Hi,

For the last 2 years, I have kept TWS consistently and constantly running through daily scheduled and every odd unscheduled restart with the need for any human intervention.

This is achieved through the help of IBC and Watchdog.

Unfortunately, with the recently mandated 2FA security measure, no restart can be completed without a human acknowledgement through the IB Key on my iPhone.

I have been searching for a remedy/workaround for weeks. The closest I have come across is to set the Lock and Exit behaviour in TWS to "Restart" instead of "Logoff", which did not improve things. It still requires the IB Key authorisation.

I would be immensely grateful if someone in the community could offer me tips/suggestions, including switching to IB Gateway if absolutely necessary to restore the convenience I used to have.

Thanks very much in advance!

I am running IBC 3.16.2+ and TWS from 10.19+ on both Linux and macOS platforms.

Chen


 

Sloppy wording on my part. "you only get a forced restart over the weekend" if you set the Gateway to auto restart


------ Original Message ------
From "Andy Webb via groups.io" <andy.webb@...>
Date 16/10/2023 18:31:04
Subject Re: [ibc] 2FA prevents TWS restarts without human authorisation

Hi Chen

I don't think there's a way round that with TWS. But it can be made reasonably painless with IBC and IB Gateway.

With Gateway you only get a forced restart over the weekend. I schedule my Gateway to shutdown early afternoon Saturday anyway and restart?early afternoon Sunday (UK time).
IBC has a really useful setting that will keep retrying if you miss the first 2FA request.

Andy
?




------ Original Message ------
Date 16/10/2023 16:40:26
Subject [ibc] 2FA prevents TWS restarts without human authorisation

Hi,

For the last 2 years, I have kept TWS consistently and constantly running through daily scheduled and every odd unscheduled restart with the need for any human intervention.

This is achieved through the help of IBC and Watchdog.

Unfortunately, with the recently mandated 2FA security measure, no restart can be completed without a human acknowledgement through the IB Key on my iPhone.

I have been searching for a remedy/workaround for weeks. The closest I have come across is to set the Lock and Exit behaviour in TWS to "Restart" instead of "Logoff", which did not improve things. It still requires the IB Key authorisation.

I would be immensely grateful if someone in the community could offer me tips/suggestions, including switching to IB Gateway if absolutely necessary to restore the convenience I used to have.

Thanks very much in advance!

I am running IBC 3.16.2+ and TWS from 10.19+ on both Linux and macOS platforms.

Chen


 

@All,

Chen and I have been working on this issue together prior to coming to this group for further insight and let me expound on what it seems is happening. We install TWS on both a ubuntu server and a macOS environment and if we run TWS manually it runs perfectly fine, however after the first run of TWS under IBC control TWS fires up, but has now become crash prone. Once TWS crashes then IBC does a hard restart of the application. It appears that its crashing during the daily restart hence the 2FA issue because of the hard restart it needs 2FA to relogin since if TWS was functioning properly it would only need 2FA once a week. In the macOS environment its more stable than in ubuntu, but in ubuntu once IBC has run TWS then TWS will crash during a number of actions on the application. It crashes not only during restart but it also crashes upon order submission, when changing the contract shown on the graph or on the order entry screen, etc.

Running TWS manually after the first run by IBC is still crash prone. Our theory is perhaps there are some settings in the IBC installation/configuration that we are missing so that when it alters the TWS files during its initial run it isn't altering the TWS files properly.

Hopefully this helps clarify what we are experiencing.

Thanks,

Brian


 

开云体育

OK, the first thing to say is that if you are experiencing problems while using IBC, you should post here and attach the IBC logfile so that I can have a look at what’s going on. And I mean attach the logfile, don’t just quote its contents inline in your post. And also, include the whole logfile – don’t try to extract the bits that you might think are relevant, because invariably when people do this it just wastes time because I just have to go back to them and ask them for the whole thing.

?

The next thing is that you should upgrade to the latest IBC version, which is 3.18.0.

?

The third thing is that you seem to have some misunderstandings about what IBC does. It doesn’t do anything at all that influences the way TWS works. It just acts like a user so that certain things happen without the user having to initiate them. So when you say things like ‘…when it alters the TWS files during its initial run..’ that’s just completely wrong. It doesn’t alter any TWS files. TWS running under IBC is exactly the same as TWS running manually, with the exception that IBC doesn’t use the script (in Linux/macOS) or the tws.exe (on Windows) that the desktop shortcuts point to.

?

And the final point is simply that you cannot avoid having to do the 2FA. The days when you could automate the whole thing and never need to have human involvement are long gone, and to be honest I’m astonished that you still seem to think that ought to be? a possibility. However if you set it up properly, all you need to do is once a week handle the alert from IB on your cell-phone or tablet: that’s about as minimal as you could ask for.

?

So in my case, I start my live TWS on Sunday evening, I handle the alert some time later (depending on when I remember and whether I have my phone handy), and that’s it: it runs flawlessly for the rest of the week until Sunday.

?

So get me the logfile please! I would appreciate it if you move to 3.18.0 before you do that – it might just make a difference; but that’s not essential.

?

Richard

?

(I’m the main developer of IBC)

?

?

From: [email protected] <[email protected]> On Behalf Of Brian Barnett
Sent: Monday, October 16, 2023 10:46 PM
To: [email protected]
Subject: Re: [ibc] 2FA prevents TWS restarts without human authorisation

?

@All,

Chen and I have been working on this issue together prior to coming to this group for further insight and let me expound on what it seems is happening. We install TWS on both a ubuntu server and a macOS environment and if we run TWS manually it runs perfectly fine, however after the first run of TWS under IBC control TWS fires up, but has now become crash prone. Once TWS crashes then IBC does a hard restart of the application. It appears that its crashing during the daily restart hence the 2FA issue because of the hard restart it needs 2FA to relogin since if TWS was functioning properly it would only need 2FA once a week. In the macOS environment its more stable than in ubuntu, but in ubuntu once IBC has run TWS then TWS will crash during a number of actions on the application. It crashes not only during restart but it also crashes upon order submission, when changing the contract shown on the graph or on the order entry screen, etc.

Running TWS manually after the first run by IBC is still crash prone. Our theory is perhaps there are some settings in the IBC installation/configuration that we are missing so that when it alters the TWS files during its initial run it isn't altering the TWS files properly.

Hopefully this helps clarify what we are experiencing.

Thanks,

Brian


 

Hi Richard,

We really appreciate your help here. Your willingness to help directly with users like us is commendable.

The ubuntu box has already been on 3.18.0 and I've attached the launcher logs for the past 2 days from the ubuntu box. I'll be so happy when I can get this running flawlessly through the week until Sunday like it should. :-)

**Note we had IBC working flawlessly on a previous ubuntu box. We migrated to a box with more processor and RAM. After the migration to the new box is when the crashing behavior started. I'll state again just for clarification that TWS runs fine on the box without crashing behavior until its run by IBC and then it become crash prone. We've reinstalled TWS to see if that was a factor. We haven't yet attempted a complete redeployment of IBC to see if we just missed something during the initial setup of IBC.

Best regards,

Brian


 

开云体育

I don’t want the launcher logs, I want the IBC logs.

?

When you run IBC a prominent banner window is displayed telling you where the IBC log is. That’s what I need. The launcher logs are written by TWS and contain nothing relevant to IBC at all.

?

Richard

?

?

?

From: [email protected] <[email protected]> On Behalf Of Brian Barnett
Sent: Tuesday, October 17, 2023 10:41 PM
To: [email protected]
Subject: Re: [ibc] 2FA prevents TWS restarts without human authorisation

?

Hi Richard,

We really appreciate your help here. Your willingness to help directly with users like us is commendable.

The ubuntu box has already been on 3.18.0 and I've attached the launcher logs for the past 2 days from the ubuntu box. I'll be so happy when I can get this running flawlessly through the week until Sunday like it should. :-)

**Note we had IBC working flawlessly on a previous ubuntu box. We migrated to a box with more processor and RAM. After the migration to the new box is when the crashing behavior started. I'll state again just for clarification that TWS runs fine on the box without crashing behavior until its run by IBC and then it become crash prone. We've reinstalled TWS to see if that was a factor. We haven't yet attempted a complete redeployment of IBC to see if we just missed something during the initial setup of IBC.

Best regards,

Brian


 

Hi Richard,

Thanks for pointing that out. I can see the Title "IbcTws" and if I click on About a small widow pops out.

Please see the image attached.

We appreciate your help and guidance immensely. Let me know how to look further to locate the actual log files.

Chen


 

开云体育

Look in twsstartmacos.sh. You’ll see the setting for the LOG_PATH variable. The log files themselves have names like this:

?

ibc-3.18.0_TWS-1025_wednesday.txt

?

Now read the descriptive comment further below. For your convenience, this is what it says:

?

#?? LOG_PATH

#

#???? Specifies the folder where diagnostic information is to be logged while

#???? this command file is running. This information is very valuable when

#???? troubleshooting problems, so it is advisable to always have this set to

#???? a valid location, especially when setting up IBC. You must

#???? have write access to the specified folder.

#

#???? If no value is set, log information is sent to the terminal window.

#

#???? If the setting is removed entirely (or commented out), no log information

#???? is captured at all (but this is not recommended).

?

I presume you are using twsstartmacos.sh to start IBC? If you aren’t, then how are you starting it?

?

?

?

?

From: [email protected] <[email protected]> On Behalf Of Chen Wang
Sent: Wednesday, October 18, 2023 8:06 AM
To: [email protected]
Subject: Re: [ibc] 2FA prevents TWS restarts without human authorisation

?

Hi Richard,

Thanks for pointing that out. I can see the Title "IbcTws" and if I click on About a small widow pops out.

Please see the image attached.

We appreciate your help and guidance immensely. Let me know how to look further to locate the actual log files.

Chen


 

开云体育

Chen, Brian, any progress, or questions, or further input on this?

?

It occurs to me that perhaps you’re using ib_insync, which I believe will start TWS for you automatically (using IBC under the hood, if I recall correctly)? If that’s the case, please let me know.

?

Otherwise, I can’t help you until you give me some information that I can use.

?

Richard


 

Hi Richard,

Apologies for the delay. Yes we are using ib_insync on a ubuntu AWS server. Since we initiated it from ib_insync we don't have the logs requested. Your previous comment triggered the idea in our minds that there was a conflict with watchdog and IBC and the auto-restart by TWS. In the meantime we have been researching discussion threads here and on the ib_insync group to understand that before responding further. We have discovered that a clean install of TWS on the ubuntu AWS box results in the freezing/crashing behavior with no involvement with IBC so clearly IBC is not related to our problem.

We see your comments on this thread:?/g/ibcalpha/topic/98487448#2079?that makes us think that perhaps the AWS box has a limited ubuntu installation and we need additional libraries. You mention installing those libraries on AWS, but any chance you can point us to a resource on what libraries would be beneficial to try installing in our ubuntu instance? Any other recommendations?

Best regards,

Brian


 

开云体育

Brian

?

That explains a lot!

?

First, my advice would be to not take ‘advantage’ of ib_insync’s ability to auto-start IBC/TWS, and just run IBC separately. I don’t use ib_insync at all, so I really don’t know how well it’s integrated with IBC , whether it would support auto-restart and 2FA etc. Ewald is a top-notch developer so more than likely he’s got it licked, but keeping them separate may be advantageous. For example, what happens if you want to run more than one API client program? Anyway, perhaps something to consider..

?

Regarding Ubuntu Server, being not a fan of Linux (my negative attitude to all things Unix goes back to the mid 1980s!) I found it a bit of a struggle to get my server up and running, but it is still running, sitting there unloved because after getting it all to work on Ubuntu I moved TWS back onto my Windows Server. And now I can’t actually remember what I have to do to even get a terminal session running on the Ubuntu Server via VNC! I’m sure I’d get the hang of it again if I spent a while trying, but I don’t feel much motivation to do so.

?

So I really can’t remember what libraries I had to install to make it work, apart from the libnss3.so, and at the moment I can’t even poke around inside it see what’s what. I’ll sleep on it, and perhaps a way forward will penetrate into my skull.

?

[Some time later…]

?

Aha, I’ve remembered how to get a terminal window visible in VNC. So I can get things like xeyes running, and I’ve still got the crontab I set up for starting IBC automatically (relevant lines commented out since I don’t wat it running there). But I’ve no idea how to discover what extra installs I had to do. So I’m not really any further forward. Any suggestions?

?

And now I really have to go to bed.

?

Richard

?

?

From: [email protected] <[email protected]> On Behalf Of Brian Barnett
Sent: Wednesday, October 25, 2023 10:58 PM
To: [email protected]
Subject: Re: [ibc] 2FA prevents TWS restarts without human authorisation

?

Hi Richard,

Apologies for the delay. Yes we are using ib_insync on a ubuntu AWS server. Since we initiated it from ib_insync we don't have the logs requested. Your previous comment triggered the idea in our minds that there was a conflict with watchdog and IBC and the auto-restart by TWS. In the meantime we have been researching discussion threads here and on the ib_insync group to understand that before responding further. We have discovered that a clean install of TWS on the ubuntu AWS box results in the freezing/crashing behavior with no involvement with IBC so clearly IBC is not related to our problem.

We see your comments on this thread:?/g/ibcalpha/topic/98487448#2079?that makes us think that perhaps the AWS box has a limited ubuntu installation and we need additional libraries. You mention installing those libraries on AWS, but any chance you can point us to a resource on what libraries would be beneficial to try installing in our ubuntu instance? Any other recommendations?

Best regards,

Brian