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

Passwords are case sensitive Issue #267

Open danielyouk opened 2 weeks ago

danielyouk commented 2 weeks ago

Hello Team,

I have got the continuously the below error as attached.

image

For better understanding, I also included my log file as well. IBC-3.20.0_TWS-1030_FRIDAY.txt

To clarify, the error consistently occurs from the second auto-restart attempt onwards, while the first attempt runs successfully with no issues.

Could you kindly review this and provide guidance on how to resolve the issue? I appreciate your support and look forward to your feedback.

Best regards, Daniel

rlktradewright commented 2 weeks ago

There have been occasional similar reports involving the 'Re-login is required' dialog, where everything falls apart.

When IBC detects that dialog, it automatically clicks the OK button. because that's the only action available to it apart from shutting down and restarting: but there are circumstances where this dialog is expected to be displayed, and IBC clicking the OK button is the correct action, whereas shutting down is certainly not correct.

But occasionally TWS displays this dialog for some (unknown) other reason, and when IBC clicks the OK button it seems that the login credentials have been invalidated, and TWS gets stuck on this 'Unrecognized Username or Password' dialog.

This is a TWS issue, or probably an IBKR account server issue. I've no idea why it happens. I've never been able to find anything incorrect in the IBC setup that night cause it. Indeed IBC is not involved at all in causing the problem in the first place. And as I said, clicking the OK button is a reasonable thing to do, indeed the only thing IBC can do.

So I don't know what to suggest.

Does this happen every time after an auto-restart? If so, can you try running TWS manually, ie without using IBC, and see if it shows the same behaviour (ie displaying the 'Re-login is required' dialog some time after the auto-restart). If it all works properly without IBC then I'll clearly have to think again.

danielyouk commented 2 weeks ago

Hi @rlktradewright, thank you for your kind answer.

I feel like my first explanation bit mislead your understanding.

IBC functions correctly overall, and I'm familiar with the process. However, the issue can be summarized as follows:

When I log in using IBC, it works as expected. The first auto-restart based on the time setting also works. From the second auto-restart attempt onward, an error occurs.

A few months ago, I tested and no error occured. However, after updating the TWS versions (offline) on several systems, including my Windows PC, Mac, and even on the cloud, the issue started occurring. I am sure this is not because of multi log on attempt because I have not applied any auto scheduling in MAC and cloud. I only did auto scheduling of my windows machine.

rlktradewright commented 2 weeks ago

I completely understood what your issue is. The IBC log file shows clearly that the first restart works, but not the second one. And as I told you, you are not the first person to have this problem.

But perhaps you misunderstood my response. So let me try to explain again.

When IBC is running, all it does is set there listening for events occurring in TWS that are reported to it by the Java run-time using standard low-level Java mechanisms. These events are user-interface events such as dialogs being displayed or closed. When such an event is reported, IBC logs it and examines it to decide whether any action needs to be taken. For example, when the login form is displayed, IBC checks to see whether it has the user id and password in its config.ini and if so, it enters them into the relevant fields in the dialog, and then clicks the Login button: in other words, it does exactly the same as a user would do, no more, no less.

Now, as you've seen, auto-restart works fine (the first time), and IBC isn't actively involved during this process, apart from logging information: TWS drives the auto-restart process automatically and there is no need or opportunity for IBC to be involved. But then, mysteriously, this 'Re-login is required' dialog appears for no apparent reason. This dialog is displayed when TWS thinks it is necessary (presumably under the direction of the IB login server): there is nothing IBC can be doing 'incorrectly' to make it appear. Presumably the stimulus for it at the IB end is that something has cast doubt on the validity of the login session, and so the user must be asked to login again (but that is speculation on my part - I don't have any real information about what condition causes this dialog to be displayed).

The thing is, the 'Re-login is required' dialog only has a single Re-login button, so all the user can do is click that button or just close the dialog (I presume that simply closing the dialog without clicking the button will result in it being re-displayed, but I can't check that because I never see this dialog!). Because IBC is running, IBC itself is the user so all it can do is the same as the user could do, so it clicks the button. But then TWS doesn't do anything sensible and it all goes to pot.

So what I'm telling you is that IBC is doing nothing more than the user would do in the same situation, and the problems are caused by TWS. In other words, this is not an IBC issue!

As a bit of further information, here are your log entries when the problem first arises:

2024-09-14 04:35:18:674 IBC: detected frame entitled: Connecting to server...; event=Activated
2024-09-14 04:35:18:676 IBC: detected frame entitled: Connecting to server...; event=Focused
2024-09-14 04:35:18:676 IBC: detected frame entitled: Connecting to server...; event=Opened
2024-09-14 04:35:21:304 IBC: detected frame entitled: Attempt 2: Authenticating...; event=Lost focus
2024-09-14 04:35:21:304 IBC: detected frame entitled: Attempt 2: Authenticating...; event=Deactivated
2024-09-14 04:35:21:304 IBC: detected dialog entitled: Re-login is required; event=Activated
2024-09-14 04:35:21:308 IBC: detected dialog entitled: Re-login is required; event=Focused
2024-09-14 04:35:21:308 IBC: detected dialog entitled: Re-login is required; event=Opened
2024-09-14 04:35:21:308 IBC: Re-login to session
2024-09-14 04:35:21:308 IBC: Click button: Re-login
2024-09-14 04:35:21:403 IBC: detected dialog entitled: Re-login is required; event=Closed
2024-09-14 04:35:21:403 IBC: detected dialog entitled: Re-login is required; event=Lost focus
2024-09-14 04:35:21:403 IBC: detected dialog entitled: Re-login is required; event=Deactivated
2024-09-14 04:35:21:403 IBC: detected frame entitled: Attempt 2: Authenticating...; event=Activated
2024-09-14 04:35:21:404 IBC: detected frame entitled: Attempt 2: Authenticating...; event=Focused
2024-09-14 04:35:21:804 IBC: detected frame entitled: Attempt 2: server error, will retry in seconds...; event=Lost focus
2024-09-14 04:35:21:805 IBC: detected frame entitled: Attempt 2: server error, will retry in seconds...; event=Deactivated
2024-09-14 04:35:21:805 IBC: detected dialog entitled: Unrecognized Username or Password; event=Activated
2024-09-14 04:35:21:808 IBC: detected dialog entitled: Unrecognized Username or Password; event=Focused
2024-09-14 04:35:21:810 IBC: detected dialog entitled: Unrecognized Username or Password; event=Opened

The first three entries happen at the start of the nightly server reset period. Normally there are no immediately following entries, because the nightly reset 'just works', but something has clearly gone wrong here.

Given that this started to happen when you upgraded to TWS 10.30, I would suggest that you should move off that version onto 10.31, and see if that helps.

danielyouk commented 2 weeks ago

Hi thank you for your detailed answer.

I will try using TWS version 10.31 again and review the log file myself. If needed, I will ask further questions here.

One additional note: The issue described below tends to occur when the internet connection is unstable. I've observed this several times. Normally, IBC handles such stress tests well. For example, during a test where the internet was disconnected for about 2 minutes, IBC usually recovers. However, in some cases, it attempts to reconnect multiple times, up to more than 10 times.

2024-09-14 04:35:21:304 IBC: detected dialog entitled: Re-login is required; event=Activated

rlktradewright commented 2 weeks ago

I don't understand what you mean. IBC has no involvment at all in connections. It logs the occurrence of any dialog displayed by TWS, but it's not responsible for causing those dialogs to be displayed.

danielyouk commented 2 weeks ago

I hope the resolution is visible.

If the internet is disconnected, then relogin attempts are continuously occuring. And since due to internet is disconnected, cannot access to TWS Server. But normally this issue is gone if internet connection is restored.

As you pointed, this is not the issue or bug of IBC. But since you mentioned this with another reason like server reset, I would like to clarify this. image

The issue of mine seems to occur during the second auto-restart trial regardless of the above cases of internet situation. As you mentioned, IBC mimics human behavior. In my observation, from the second auto restart trial, the issue occurs. I have no clue what is the reason of this issue if anyone like you also does not know.

If anyone like you can have better overview for the situation and if already several cases are reported, I will be the one who will be waiting any information to resolve.

rlktradewright commented 2 weeks ago

The screenshot you gave shows perfectly normal behaviour when TWS loses the internet connection to the IB servers for any reason. It shows TWS trying to re-establish the connection and the login session. IBC is not involved in this process at all, except to log the dialog(s) that are displayed (if you look in the IBC log for the time shown, ie around 17/09/24 13:04:37, you'll see the entry for the "Attempt 7: connection error..." message box (I'm not sure exactly what the log entry will say). This is purely information reporting: IBC doesn't take any action at all in response to these.

Note that this screenshot is a completely different scenario from the one you raised this Issue about: your original logfile shows the "Re-login required" dialog occurring at the start of the nightly server reset period after an auto-restart. As I've said already, that seems to be caused by problem at IB's end.

Could I ask you again to try running TWS without using IBC and letting it auto-restart. To do this, just double click on the tws1.exe program in C:\Jts\1031, and log in manually. Then just leave it to run: it should do the first restart ok, and then hit the same problem after the second restart, probably around 04:35. If it does, you can then submit a fault report to IB with the TWS logfile as evidence.

Please make sure that you have the latest version of TWS 10.31.1i installed.

Also I presume you're aware that you have to shut down TWS completely at some point on Sunday? If you try to keep it running all the time via auto-restart it will eventually fail to do it.

danielyouk commented 2 weeks ago

@rlktradewright, thank you for your kind answer, and really appreciate your effort for the repository.

I believe you are correct. Now I totally understand what you mean after multiple ask and reply.

Now I review all my log files, and all log files show the same pattern. This same error occurs around 04:32 ~04:35 based on german time. I will ask to IB directly and again thank you for your time and effort.