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
986 stars 175 forks source link

Login failed - Server disconnected, please try again #142

Open wsj3000 opened 2 years ago

wsj3000 commented 2 years ago

Sometimes I got this pop-up window it says: 'Login failed - Server disconnected, please try again'. And if I didn't click the button 'OK' to confirm, it seems the TWS will not try to connect again and then the connection lost. After I anaylisis the log in attached file, I found that it happened in server rset time (such as Second reset: 20:15 - 21:00 HKT ). As my TWS server is in HongKong, so it seems it was coursed by server reset. Anyway, for this problem, if IBC can add new auto click button behavior to confirm to reconnect to server when login failed? After all, the connection maybe lost by other reasons and we need keep TWS online again ASAP. Thank you very much.

BTW, you can found server reset time here: https://www.interactivebrokers.com/cn/index.php?f=2225

ibc-3.10.0_TWS-978_Thursday.txt ibc-3.10.0_TWS-978_Friday.txt ibc-3.10.0_TWS-978_Saturday.txt

rlktradewright commented 2 years ago

TWS 978 is out-of-date, and your version (978.2f) is even more out-of-date (note that 978.2h was dated 7 Oct 2020, and yours is even older). I don't want to spend time catering for a situation that no-one else seems to have encountered and that may not apply to current versions.

So please update to the current stable version of TWS (981.3c at the time of writing) and try again. If it still happens, I'll take a closer look.

Your logfile actually shows up another problem that I do need to address. It shows that you have a 'white label' "Snowball Securities" version of TWS. Unfortunately this results in IBC not recognising the main TWS window, which has a number of potential problems, not least that IBC won't be able to access the Global Configuration dialog. I'll have to amend the main window recognition code to avoid this. I'll do this some time soon, but it probably won't be today.

deanb2 commented 2 years ago

Actually I have seen this happen with gateway 981.3c. Gateway unexpectedly exited during IBKR's nightly maintenance period, and was stuck at the same dialog.

Unfortunately it was more than a week ago, so I don't have the log. If it happens again (and it does happen from time to time) I will forward the log.

Dean

On 9/27/2021 8:00 AM, Richard L King wrote:

TWS 978 is out-of-date, and your version (978.2f) is even more out-of-date (note that 978.2h was dated 7 Oct 2020, and yours is even older). I don't want to spend time catering for a situation that no-one else seems to have encountered and that may not apply to current versions.

So please update to the current stable version of TWS (981.3c at the time of writing) and try again. If it still happens, I'll take a closer look.

Your logfile actually shows up another problem that I do need to address. It shows that you have a 'white label' "Snowball Securities" version of TWS. Unfortunately this results in IBC not recognising the main TWS window, which has a number of potential problems, not least that IBC won't be able to access the Global Configuration dialog. I'll have to amend the main window recognition code to avoid this. I'll do this some time soon, but it probably won't be today.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/IbcAlpha/IBC/issues/142#issuecomment-927902932, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALAAGOV4XJ76D4JLNUHZYDUEB2HHANCNFSM5EZTEPRA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

rlktradewright commented 2 years ago

Ok thanks for that info.

I'll do something to handle that dialog when I get have some time. It would be helpful if you could confirm that clicking the 'OK' button does actually cause reconnection to happen: ie you don't have to actually restart TWS/Gateway.

wsj3000 commented 2 years ago

TWS 978 is out-of-date, and your version (978.2f) is even more out-of-date (note that 978.2h was dated 7 Oct 2020, and yours is even older). I don't want to spend time catering for a situation that no-one else seems to have encountered and that may not apply to current versions.

So please update to the current stable version of TWS (981.3c at the time of writing) and try again. If it still happens, I'll take a closer look.

Your logfile actually shows up another problem that I do need to address. It shows that you have a 'white label' "Snowball Securities" version of TWS. Unfortunately this results in IBC not recognising the main TWS window, which has a number of potential problems, not least that IBC won't be able to access the Global Configuration dialog. I'll have to amend the main window recognition code to avoid this. I'll do this some time soon, but it probably won't be today.

(1)New version TWS 981.3c. also has this problem, you can found it in here. ibc-3.10.0_TWS-981_Friday.txt

(2)My account of IB applied through Snowball, so you can see 'white label' "Snowball Securities". Also I downloaded TWS from IB Official website, nothing changed by Snowball. (Snowball X outsources the clearing and settlement processes of its securities trading business to IB LLC)

wsj3000 commented 2 years ago

Ok thanks for that info.

I'll do something to handle that dialog when I get have some time. It would be helpful if you could confirm that clicking the 'OK' button does actually cause reconnection to happen: ie you don't have to actually restart TWS/Gateway.

I have clicked OK button for times, yes, TWS will try to reconnect to server and online again after a while.

rlktradewright commented 2 years ago

Fixed in Release 3.11.0

tredondo commented 2 years ago

I still saw this issue with v3.11.0:

image

image

I did use an older Gateway version (972), because the newer ones can't be made to run indefinitely.

rlktradewright commented 2 years ago

As a first step, please attach (don't quote inline) your IBC logfile.

tredondo commented 2 years ago

ibc-3.11.0_GATEWAY-972_Tuesday.txt

Here's the log. Thanks for taking a look.

rlktradewright commented 2 years ago

Thanks for the logfile. As it happened it didn't add any new information, but it ruled out a few possibilities.

But I've been stupid: I didn't look closely enough at your screenshots in comparison with the earlier ones, and it's fairly obvious that IB have changed both the dialog title and the first part of the message itself; or perhaps this is just slightly different circumstances; or it's just different in version 972. Either way, IBC doesn't recognise the dialog and ignores it instead of clicking 'OK'.

I'll try to get a new release out soon. There are some other items for release which need some finalisation, but that won't take too long. In the meantime, apologies for the inconvenience if this problem keeps occurring.

tredondo commented 2 years ago

No worries, thank you so much for the help and for all your work!

rlktradewright commented 2 years ago

I've just made a new release, 3.11.1, to address this problem.

Waiting until the other items I intended to release are ready would have taken too long.

tredondo commented 2 years ago

Thank you! New release has been deployed after the market close. Will update in a few days.

tredondo commented 2 years ago

Seemed to work fine over the weekend, until it ran into an apparently different issue: #153.

tredondo commented 2 years ago

Just ran again into this issue, with 3.12.0-beta.2, after about a month of running that version without any incident.

image

Logging stopped on Fri Jan 7, at 23:59 NYSE time.

ibc-3.12.0-beta.2_GATEWAY-972_Saturday.txt

rlktradewright commented 2 years ago

@tredondo

So in spite of everything that IB has been announcing regarding the Log4J issue, you've continued to run Gateway 972 for an entire month? It may be that it is still working well, in spite of what IB said about these old versions not working after 29 December 2021, but surely you can see that the writing is well and truly on the wall and could hardly be writ larger: it's time to upgrade to 981.

From your screen shot and your logfile it seems as though the Gateway was in the process of closing down. I cannot see any reason why IBC did not recognise that dialog and click the OK button, but for some reason it didn't.

I don't propose to spend any more time on this, and in general I don't intend to provide any significant support to users who continue to try and run these old versions. It's just a complete waste of my time.

So please, do yourself a favour and upgrade. If you still encounter the same problem with 981 or 1012, then I'll be happy to take another look.

As an interim piece of advice, if you want to continue with 972 (if indeed it still works at all) while you get yourself sorted out with 981, then just run it for a week at a time at most instead of trying to run it forever.

mauerdev commented 2 years ago

I have a similar issue. It prompts to confirm reconnect in the middle of the night. I have tried stable and latest. Is there a solution for this?

rlktradewright commented 2 years ago

@mauerdev IBC logfile please.

mauerdev commented 1 year ago

api-exported-logs.txt tws-exported-logs.txt This is happening again on multiple accounts. It seems to be happening with increased frequency. It happens around 10MST almost every night. After clicking Re-login multiple times, it continues to fail to recognize a password. It locked me out after repeated attempts. The only choice is to close the application when this happens.

rlktradewright commented 1 year ago

Actually it was the IBC logfile I asked for, not the TWS and API logs.

However, the TWS logfile seems to indicate that the session was disconnected at around 2022-08-02 00:15:26, and its attempt to re-login failed because of a competing session (ie another instance of TWS or Gateway running under the same user, or the IBKR Mobile app logged in and using data, or the client portal logged in and using data).

Does that sound like what might be happening?

If so, you can protect against this by setting:

ExistingSessionDetectedAction=primary

in your config.ini. Then, if anything attempts to start a competing session, IBC will handle the relevant dialogs to prevent that new session from proceeding.

mauerdev commented 1 year ago

I am not sure how to export IBC logfile. To my knowledge, there are no other attempts to start a competing session, and this occurs about the same time every night. I will see if changing the setting has any effect.

rlktradewright commented 1 year ago

Every time you run IBC, there is a big friendly window displayed which tells you exactly where the IBC logfile is. It's just a text file, so there is no need to 'export' anything.

OakvilleTrading commented 7 months ago

I have the same error with TWS10.26.

rlktradewright commented 7 months ago

How frequently? Which day(s) of the week? Did it happen with previous TWS versions? Attach IBC logfile please.

windowshopr commented 5 months ago

I got this same issue today on Windows 10. Currently trying to log in to IB Gateway on a Saturday so that could be an issue in and of itself. The issue started after the weekly scheduled maintenance on Friday night while IB Gateway was still logged in (started doing the "attempting to reconnect" thing as it usually does). IB Gateway shuts itself down after 11:45 PM as per my settings.

See the screenshots below (I can't get past the login screen so there is no log to show):

image

image

I can log in to the IB website (so it's not a credentials issue), just not the TWS or IB Gateway.

I can connect to the Paper Trading version of IB Gateway, but not the Live Trading portion.

The current version information about IB Gateway is below:

image

image

I realize this isn't an issue with this repo, but IB, however I found this thread and wanted to post some of the info I could on it as the OP is not alone! Hopefully it figures itself out for next week.

rlktradewright commented 5 months ago

There is an IBC logfile as soon as you start IBC. The banner window tells you where it is.

However in this case I don't actually need it because I've already seen some logs from this situation. And in fact I've added an enhancement to IBC to (hopefully) cope with this. It will detect this particular dialog, shut down IBC/TWS/Gateway, and then restart everything (thus requiring full 2FA).

It's a bit difficult to know if this enhancement works properly, because i can't force this to happen, so time will tell. If there's something wrong at the server end, there's a possibility that the same thing will just happen again

I'm not quite ready to release this yet as I have to make some other changes that need a bit more work, but it shouldn't be long.

OakvilleTrading commented 5 months ago
Screenshot 2024-02-15 at 7 50 46 AM

I get this screen every time. I do not log in since last Dec. It is version 10.26, offline. Cannot install online version. Always got some java error.

rlktradewright commented 5 months ago

As I said in my previous post, I've done an update to IBC that addresses this issue, but I haven't released it yet. I will do so soon.

However, if you get this problem every time you run IBC, that suggests to me that there is something fundamentally wrong somewhere. So the chances are that my updated version will handle this dialog by restarting IBC and attempting the login again, but will just fail again in the same way.

By the way, I notice that I asked you on Dec 28th to attach your IBC logfile, but you haven't responded. Sending me screenshots that others have already sent is not going to help. Sending your logfile just might.

OakvilleTrading commented 5 months ago

Here are the log texts. I run 10.26 standalone version

image

Exception found -

java.lang.UnsupportedOperationException: Toolkit.getLockingKeyState at java.desktop/sun.lwawt.macosx.LWCToolkit.getLockingKeyState(LWCToolkit.java:522) at twslaunch.jclient.login.a.e(a.java:622) at twslaunch.jclient.login.a.a(a.java:599) at jclient.LoginFrame.main(LoginFrame.java:469) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:84) at com.install4j.runtime.launcher.MacLauncher.main(MacLauncher.java:52)

rlktradewright commented 5 months ago

@OakvilleTrading

I asked you for your IBC logfile, but you've sent me a screen grab of a tiny portion of the TWS logfile, which is completely useless.

When you start IBC you get a nice banner window that tells you exactly where the IBC logfile is. That logfile gives me a large amount of information that is often extremely helpful in diagnosing problems.

So attach that (as a text file): don't quote it inline, and don't edit it.

OakvilleTrading commented 5 months ago

I have problem with TWS. Not IBC. Now I know I am in the wrong place to fix my issue.

frucode28 commented 3 months ago

@OakvilleTrading Have you managed to solve this issue? I also have the same one.

rlktradewright commented 3 months ago

I've been reviewing some of the IBC code, and have improved a couple of things that may have a bearing on this issue.

Here's a link to a new beta version of IBC v3.19.0-beta.1:

https://1drv.ms/f/s!AlqfLEOWDJ9Zh-klxayDSKUDSpj0Ow?e=LUbIce

For both Windows and Linux/macOS users, you'll need to extract the updated IBC.jar and version files to your IBC folder.

For Windows users only, you should also extract the StartIBC.bat file to the scripts subfolder in your IBC folder. And also extract the config.ini file, carrying forward your settings to the new version.

You may notice that there is a new ColdRestartTime setting in config.ini. I haven't yet decided whether to keep this feature going forward with IBC, so you can use it if you want but I may remove it (though if people find it useful I'll probably keep it). However note that this feature doesn't work properly on Linux/macOS as the scripts need some updates to support it: I'll do these if I decide to keep the feature.