-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constantly getting "Gateway session active but not authenticated" #7
Comments
Nevermind. I had to explicitly log out from my web session :) |
Hey thanks for reporting and following up on this issue! 👋 |
Hmm, I started playing with the timeouts (because I was running out of time to do 2FA) and now I'm getting this issue fairly consistently. Here is a snippet of the logs
Tried restoring the constants to their original values with no luck. This is on Any idea of how to make the issue less likely to happen? Edit: reverted to |
Hey @Proksima thanks for reporting this issue! 😊 Let's try to figure out why are you running into these errors that often. Firstly though - unless I'm mistaken the log you pasted is from the older version, probably I made some improvements to the authentication and ensuring that the gateway is running before attempting to communicate with it on the recent release candidates - I'd like to verify that you're running into these issues despite these improvements. Also - do I understand correctly you manually complete 2FA with your phone when IBeam is trying to authenticate? If so, I'm assuming the timeout happens after you complete 2FA, not before it, right? Lastly, you wrote "I started playing with the timeouts (because I was running out of time to do 2FA) and now I'm getting this issue fairly consistently." - does that mean you weren't running into this issue that often before you started changing the timeouts? |
I will come around and retry probably tomorrow or this weekend, but I will answer what I can in the meantime. "Firstly though - unless I'm mistaken the log you pasted is from the older version, probably latest ie. 0.2.1. Can you confirm that this also happens on 0.3.0-rc2 and possibly paste the log from that version here too?" I was under the impression my tests were on 0.3.0-rc2, but now you have me doubting; I will make sure that I was not using an older image by mistake. "Furthermore, you can try turning on more verbose logging by setting IBEAM_LOG_LEVEL to DEBUG - this could tell us more about the cause too." Will follow up on this next time I have a chance to work on it. "Also - do I understand correctly you manually complete 2FA with your phone when IBeam is trying to authenticate? If so, I'm assuming the timeout happens after you complete 2FA, not before it, right?" The first 2FA prompt makes IBeam goes to "Logged in but not authenticated." On the next authentication attempts I do not get a 2FA prompt. "Lastly, you wrote "I started playing with the timeouts (because I was running out of time to do 2FA) and now I'm getting this issue fairly consistently." - does that mean you weren't running into this issue that often before you started changing the timeouts?" It used to work flawlessly all the time. I mentioned this, but at the same time, I think its a coincidence. Otherwise, it would imply that this would have a lasting impact on my authentication which does not make sense to me... but I could be wrong. I think low key I played with them because I thought I was missing the 2FA and then it just made the problem more obvious. I doubt it actually contributed... |
Great, thanks for filling me in on more details!
This seems to indicate something indeed started going wrong afterwards. Could it be maybe you got locked out due to failed 2FA attempts? Can you still login to TWS using the same credentials? I'm thinking the |
I run into this too if I'm logged in somewhere else but also just seen to have it happen every once in a while. I usually stop iBeam and log in manually, go to trade tab hit the take over button, then log out. |
Okay, fairly sure I'm on I am now getting a different behavior: 2FA is asked at every authentication trials. Didn't work on the first trial but worked on the second (more consistent with what I read on this thread). Here are my logs for this trial: ibeam.log.txt Since it now works and I can't guarantee it will stop working on 0.3.0-rc2 (still unsure what I was using before because I was not specifying the version for the docker_container in my configuration; could have been either since both were available). I think this ticket can be closed? I am leaving DEBUG on (there are very little debug logging anyway) and if it every does that weird behavior again I'll make sure to re-open and attach the full log. Thank you for the pointers! |
Thanks for leaving some feedback in that regard @gmcmicken! For sure having the same credentials used will cause authentication errors along these lines. I'm curious to see whether the localhost:5000 login page displays some 'take over the credentials' button when this happens, that we could potentially click at that stage - may do some more research into that.
Yupp, that sounds like previously you were running
Right, thanks for reporting that. Frankly, IBeam also sometimes fails to authenticate for me on the first one or two attempts - I just kind of waved it off as this seems to be internal IB stuff figuring out the permissions and it seems to resolve itself after a while. Definitely a good idea to have that behaviour accounted for in the code that uses IB. My system will attempt to execute its requests on a repeated basis until all of them succeed - although this can also be potentially risky if care isn't put into preventing double requests. Nevertheless - if you can think of some ways we could improve the authentication or are running into some other unexplained issues, do let me know. Happy we managed to get you up and running again! Thanks! 👋 Voy |
can you please elaborate on exactly how do you do this? Are you doing it from the IBKR Trader Workstation (where we can place trades) or in AccountManagement (where we only see the portfolio)? And how exactly to do it. I have two paper-trading accounts and in one, there is no problem and in the other one it has this issue of repetitive To be exact, it was running well, then this happens,
and it has been the same since. Thanks in advance. |
Hi, Sorry for the trouble, but the error was resolved by changing the |
I am receiving the same message, after I made successful authentication. But I am not using 2FA. Is it possible that I am getting this error because I don't have 2FA active? |
@MislavSag We haven't seen any relationship between this error message and the 2FA. As far as we can tell now this seems to be a periodic issue with IBKR |
@Voyz since this seems like a common issue, if possible can you improve iBeam to automatically detect continuous As of now, I am facing this problem, so I continuously check the status just before the market open and if the gateway is not authenticated I change the |
That's a great idea @Wenuka 👏 Definitely worth exploring. I'm currently unavailable to implement such a fix, so feel free to propose a PR, but otherwise I'll look into it once I find some time |
Maybe a simpler solution would be to automatically log out when the issue is identified https://localhost:5000/v1/api/logout That seems to work for me |
@popiol thanks for leaving this suggestion, I'll try to implement it first and see if it helps with the problem. There's been another report that |
@popiol @Wenuka @AndreaOrru @Proksima @gmcmicken new release candidate image |
Looks good for me: 2021-10-06 05:23:28,688|I| Gateway session found but not authenticated, authenticating... |
Hi,
Then I killed the docker session and re-run using the changed P.s: Thank you in advance. |
Thanks for reporting back @Wenuka 👍 It sounds like we may want to resort to proxy wrangling. Due to workload I won't have time to look into it in the few upcoming weeks, so feel free to propose a PR handling this functionality in the meantime. As for manually logging in every week - could you link up the documentation you're referring to? I think due to all the various errors I never had the Gateway continuously authenticated for as long as a week, so it's hard for me to tell if that could cause any issues, but thanks for highlighting it as a potential problem. |
@Voyz Thanks for releasing
One small thing maybe would be to stop the maintance when doing the logout and restart it once the gateway has been restarted. |
Thanks for reporting @DanielHTpg very glad to hear the new fixes are working for you 👍 Also good suggestion, I'll look into stopping maintenance during restart, thanks! |
Running into these intermittent connection issues as well. Hitting However even with IBeam still thinks the
I dont understand how Interactive Brokers can offer such a poorly designed and implemented API. How are you supposed to automate trading if you have to re-auth every hour/day and the API is broken? |
sorry to hear @jonbattista have a look at #38 - this would be the issue you're encountering |
For what it is worth: I also get the |
@10ne1 if I understand it correctly what you're seeing is expected. You can use one login credentials only for either the Client Portal Web API or for Web/Mobile app. The issue others are describing here is that even when not logged in elsewhere the CP Gateway will start returning this error message. |
@Voyz Thanks, I'll have to do more observations to figure out if all my current error message are due to being logged into web/mobile or if I also receive errors without being logged in. I have upgraded to What does happen though is sometimes I get logged out after a few hours, then ibeam does the auth dance again as expected in rc1. I do however note that I need to completely log out from web/mobile: any lingering web/mobile session, no matter how old, even in read-only mode can cause the error to appear. |
Let us know how the 0.4.0 versions are working for you - has it helped with the repeated |
I am not having an issue with IBeam but there has been a weird problem lately. If I run get requests related to account such as sorry I had to write this here because there are not many forums to discuss this. |
@murtazayusuf you may be experiencing a similar issue as the one described in #38. If you feel that this is a different problem then I'd suggest you open a new issue, as this one is mainly related to authentication problems, rather than empty responses. If you aren't sure if it's due to market closed or not, I'd suggest to run both IBeam and the Gateway tests one after another during opening hours and verify this assumption then. |
Thanks @Voyz . |
To anyone involved - seeing I haven't heard back regarding this issue I'm going to be looking at merging the |
Closing this as |
Hello 2023-01-31 16:13:13,534|I| No active sessions, logging in... |
@mujtabaanwer I wish I could help you here, but we haven't been able to identify the cause of this issue appearing. The best I can suggest is talking to IBKR support and letting them know that your sessions' authentication is not working and see if they can help. |
Describe the bug
After logging in and authenticating through 2FA via the IBKR mobile app, the login succeeds, but the session immediately appears as non-authenticated:
And it constantly asks me to login again.
I seem to be able to make some requests anyway: i.e.
/portfolio/accounts
works just fine.But
/portfolio/{accountId}/positions/0
doesn't work.To Reproduce
Steps to reproduce the behavior:
Expected behavior
After login succeeds, the gateway session should be and stay authenticated.
Environment
IBeam version: 0.2.0
Python version: 3.7.7
OS: Linux
(running on the default Docker image)
The text was updated successfully, but these errors were encountered: