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
974 stars 174 forks source link

Failed to Re-Login #246

Open akatsev opened 6 months ago

akatsev commented 6 months ago

Hi,

This morning I've got the same picture, but now there are no messages Couldn't write to log file - java.io.IOException: write beyond end of stream in the IBC log. Initially there were lines up to 530 and then I pressed several times OK button on LOGIN FAILED dialog and then lines 531-588 were added. Eventually I closed IBC (line 589)

I hope for your kind help, Sincerely, A. Katsev. IBC-3.18.0_TWS-1026_SUNDAY.txt

rlktradewright commented 6 months ago

Ok, thanks.

Let me make an observation: there is absolutely no doubt that when a user sets up IBC by following the instructions and the locations and settings described in the User Guide, it just works. It's very simple to set up, there's hardly anything one needs to change, and it's all very straightforward.

So when someone reports that it's not working for them, it's clear to me that they've done something that's causing a problem.

Thus, what we have to find out here is what's different about your setup that is the cause of the problem. The actual way the problem manifests is that around 05:15 to 05:20, your TWS login is invalidated and it wants you to login again. Now, it would probably be possible to amend IBC to literally login again at this point, but I don't want to do that, because you really don't want to be having to do a 2FA login at that time every morning when you run your live account.

After spending a lot of time going over your logfiles and considering all the evidence, I think that I can definitely rule out the following non-standard aspects:

First, I don't think the fact that you're running under Administrator is likely to be the cause. I really do think this is not a good idea, and I would urge you to reconsider that, but I think that's just a distraction here.

Secondly, the fact that you have relocated the built-in Java VM to Program Files\Common Files shouldnb't be an issue. I actually do something very similar myself, so that TWS is installed by a user with administrative privileges, but runs under an ordinary unprivileged user.

The only thing I can see that might be an issue here is that your country is US, but your timezone is UTC. I can't imagine the mechanism by which this might cause the problem, so I'm clutching at straws here. But it's interesting that the time this problem occurs is during the nightly server reset period, so perhaps this arrangement is confusing something n IB's account server.

So here's what I'd like you to do:

  1. Change your TWS timezone to be your normal local timezone for your location, and run it again.

  2. If that doesn't help, then make the foliowing settings in config.ini (these settings are near the end of the file)

    LogStructureScope=all LogStructureWhen=activate

    Then run IBC until the 'Login failed' dialogs start happening around 5:15. Attach the logfile to your reply. This will collect a lot of information that will enable me to see exactly what TWS is displaying. Whether this info will actually help is another matter: time will tell...

And if none of this helps, the only thing left to suggest is that you just wipe out your IBC installation, uninstall and reinstall TWS from scratch, and set up IBC again following the instructions exactly.

akatsev commented 6 months ago

Dear Sir, Let me express my endless gratitude to you for the great effort you put into developing and maintaining such a wonderful, sophisticated and widely available software product as IBC, and in particular for the attention you give to my issues.

As for your recommendations, I will certainly follow them, but in due course I will note that I did not choose the UTC settings by chance. In the future, we plan to work on the same project on different accounts in different regions. In addition, as I have noticed, the problem appears on Sundays. So I'm planning to do your recommended experiment next weekend.

With sincere respect and appreciation, Aryeh Katsev.

пн, 25 дек. 2023 г. в 23:34, Richard L King @.***>:

Ok, thanks.

Let me make an observation: there is absolutely no doubt that when a user sets up IBC by following the instructions and the locations and settings described in the User Guide, it just works. It's very simple to set up, there's hardly anything one needs to change, and it's all very straightforward.

So when someone reports that it's not working for them, it's clear to me that they've done something that's causing a problem.

Thus, what we have to find out here is what's different about your setup that is the cause of the problem. The actual way the problem manifests is that around 05:15 to 05:20, your TWS login is invalidated and it wants you to login again. Now, it would probably be possible to amend IBC to literally login again at this point, but I don't want to do that, because you really don't want to be having to do a 2FA login at that time every morning when you run your live account.

After spending a lot of time going over your logfiles and considering all the evidence, I think that I can definitely rule out the following non-standard aspects:

First, I don't think the fact that you're running under Administrator is likely to be the cause. I really do think this is not a good idea, and I would urge you to reconsider that, but I think that's just a distraction here.

Secondly, the fact that you have relocated the built-in Java VM to Program Files\Common Files shouldnb't be an issue. I actually do something very similar myself, so that TWS is installed by a user with administrative privileges, but runs under an ordinary unprivileged user.

The only thing I can see that might be an issue here is that your country is US, but your timezone is UTC. I can't imagine the mechanism by which this might cause the problem, so I'm clutching at straws here. But it's interesting that the time this problem occurs is during the nightly server reset period, so perhaps this arrangement is confusing something n IB's account server.

So here's what I'd like you to do:

1.

Change your TWS timezone to be your normal local timezone for your location, and run it again. 2.

If that doesn't help, then make the foliowing settings in config.ini (these settings are near the end of the file)

LogStructureScope=all LogStructureWhen=activate

Then run IBC until the 'Login failed' dialogs start happening around 5:15. Attach the logfile to your reply. This will collect a lot of information that will enable me to see exactly what TWS is displaying. Whether this info will actually help is another matter: time will tell...

And if none of this helps, the only thing left to suggest is that you just wipe out your IBC installation, uninstall and reinstall TWS from scratch, and set up IBC again following the instructions exactly.

— Reply to this email directly, view it on GitHub https://github.com/IbcAlpha/IBC/issues/246#issuecomment-1869151867, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE44OAGOUNCKNCKSCPJJJULYLIEQJAVCNFSM6AAAAABBCK2VTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRZGE2TCOBWG4 . You are receiving this because you authored the thread.Message ID: @.***>

rlktradewright commented 6 months ago

You say the problem appears on Sundays.

In that case, maybe you're not aware that you have to restart TWS and do a full logon every Sunday (incluiding 2FA if it's a live account)? You can't just let TWS keep running through the weekend. This is a hard-and-fast IBKR security rule, and IBC can't do anything about it.

So you need to make sure that TWS is shut down and restarted at some point on Sunday. The easiest way to do this is to set the ClosedownAt setting in config.ini. For example

ClosedownAt=15:00

Then restart TWS at some later point (you can automate this with Task Scheduler of course).

I didn't mention this before because: 1. You didn't say that the problem only occurred on Sundays; 2. The logfiles didn't appear to have the right information for this scenario; 3. I assumed that you were aware of the limitations of auto-restart.

So please check this out to make sure you're complying with the rule.

By the way, I urge you to think long and hard about the UTC aspect: the fact that you intend to operate your project in different regions doesn't strike me as being a reason to use UTC: it will create as many problems as it solves. But that's another topic...

akatsev commented 6 months ago

Well, regarding Sundays - it was my initial impression, but tonight it appeared as well. So I'm going to try to change my time settings today. Additionally, your clarification that IBC can't overcome Sunday's re-login was very valuable for me. I didn't succeed to understand this from the documentation. Regarding UTC I'll think about it more... One of the reasons was not to deal with daylight saving time.

Thanks a lot, A. Katsev.

ср, 27 дек. 2023 г., 13:24 Richard L King @.***>:

You say the problem appears on Sundays.

In that case, maybe you're not aware that you have to restart TWS and do a full logon every Sunday (incluiding 2FA if it's a live account)? You can't just let TWS keep running through the weekend. This is a hard-and-fast IBKR security rule, and IBC can't do anything about it.

So you need to make sure that TWS is shut down and restarted at some point on Sunday. The easiest way to do this is to set the ClosedownAt setting in config.ini. For example

ClosedownAt=15:00

Then restart TWS at some later point (you can automate this with Task Scheduler of course).

I didn't mention this before because: 1. You didn't say that the problem only occurred on Sundays; 2. The logfiles didn't appear to have the right information for this scenario; 3. I assumed that you were aware of the limitations of auto-restart.

So please check this out to make sure you're complying with the rule.

By the way, I urge you to think long and hard about the UTC aspect: the fact that you intend to operate your project in different regions doesn't strike me as being a reason to use UTC: it will create as many problems as it solves. But that's another topic...

— Reply to this email directly, view it on GitHub https://github.com/IbcAlpha/IBC/issues/246#issuecomment-1870211255, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE44OAESSG5DWZUBHWXDGRLYLQAOLAVCNFSM6AAAAABBCK2VTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZQGIYTCMRVGU . You are receiving this because you authored the thread.Message ID: @.***>