-
Notifications
You must be signed in to change notification settings - Fork 121
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
503 Service Unavailable (IBKR/Gateway issue) #38
Comments
@isque03 brought this discussion over from #19. Thanks for being very detailed once again, great information.
Have you considered doing it? Would it be as simple as adding a HTTP request to your existing flow to verify this theory? |
Giving it a try tonight. The document here isn't quite correct:
The response is a bit tougher: The challenge is needed to calculate the challenge response, or R whereby seed = challenge, verifier = st. To calculate R, ensure both the challenge and session token calculated during initial authentication are in hex form. Then, concatenate the challenge and session tokens, with the challenge being in front. The problem here is I'm not sure we have access to the "session token" referred to in the document. I can see in the gateway logs it prints the session token out as "K=". It also prints K=XXX for the final challenge response, not the session token. So, that's a bit confusing. Using test values from the log. This will calculate the correct response value given the challenge, plus the session token.
Almost there.. Just need to figure out how to get the session token! I noticed the /v1/api/tickle endpoint returns a property called session in its response. But this doesn't seem to be the correct value. It never matches K= in the logs and when I use that to calculate the response I just get a 10 second delay, then a 503 response. |
Just an update here. I wasn't able to get the session token. But it looks like it's available during the initial SSO process. This is the SSO process that is done through the browser. I have found that it is stable if I only login in one place. Still testing with paper account, so I basically just don't log into that account except through the gateway. IBKR allows creating additional login accounts, so for live trading it's probably best to create a new login account that is dedicated to iBeam / gateway logins. |
Thanks for the updates on this @isque03 👏 I haven't got anything to comment on the process at this stage, but I appreciate you sharing the results of your attempts. Good observations on logins 👍 |
I am using Ibeam log IBKR Gateway log |
@DanielHTpg thanks for suggesting cleaning out the container daily - that's an interesting observation. Anyone else here tried this method and can comment on its results? Also, that suggestion to keep the requests repeating is good to point out - thanks for sharing it and that output from your trading system.
@alex1999Tra that's new, I don't think anyone encountered this yet, we've seen 503s on that endpoint so far. I'd suggest getting in touch with IBKR support and trying to see what they say about it. |
@Voyz The issue with no accounts being returned was one of the biggest problems I had after switching the |
any update on this issue? |
@eswark18 I'd suggest highlighting it with IBKR, as this is an internal server error reported back to IBeam |
I'm seeing the same issue. When I place an order then call iserver/reply, I'm getting:
|
I'm going to close this issue due to inactivity. Thanks for your contribution and please feel free to reopen if you'd like to continue the discussion 👍 |
This helpful comment by @demansou could help address 503 error: #147 (comment) |
Hello, Voyz. Thank you for this excellent service. However, I am encountering a 503 error again. I tried modifying I also attempted logging in via the mobile version with the same API credentials and then forcefully logging out from the mobile version. Unfortunately, nothing helped—I still receive a 503 error when trying to place an order. However, I have no issues retrieving my portfolio positions. What can I do now? |
@gikeberyfinn thanks for your kind words and sorry you're running into 503. Other than reading other users' suggestions, I'd say getting in touch with IBKR support and talking to them about it would be the best choice, as this is unrelated to IBeam itself |
@Voyz I asked them, and they requested some logs. I don’t understand where to find them. Do I need to enable some kind of debug mode? Could you please advise? "we would need you to generate .har logs for us.
|
Describe the bug
IBKR/Gateway sometimes runs into returning a 503 Service Unavailable error. In this issue we try to understand what can be done to overcome it.
Environment
IBeam-independent, it is the Gateway's issue
Additional context
So far it has been observed when calling:
/iserver/account/{accountId}/orders
In #7 (comment) @Wenuka outlines:
when I tried to place an order (using
https://localhost:{port_num}/v1/api/iserver/account/{accountId}/orders
API) I am getting a 503 response as below,Then I killed the docker session and re-run using the changed
proxyRemoteHost
value and it worked as expected.In #19 (comment) @isque03 outlines:
Gateway logs show this:
The only workaround I have found so far is to manually log into IBKR on the mobile app (or I suppose web/desktop). It will say "another session is in use, disconnect?" I click "yes" to disconnect, then I explicitly click the logout in the mobile app. After this I'm able to get a properly working brokerage session from the logout/reauthenticate flow.
My suspicion is that it's the call for brokerage session ssodh/init that the gateway makes.
See this document again: https://www.tradersinsight.news/ibkr-quant-news/tutorial-web-api-connect-to-brokerage-session/
Specifically the compete param in here:
`SSODH Init Request
POST https://api.ibkr.com/v1/api/iserver/auth/ssodh/init
The body, of type x-www-form-urlencoded, must have the following parameters:
The compete param here recommends setting it to false. What I think this does is trigger any other brokerage session to be invalidated, and allow a new one to be created. Setting compete "true" I beleive means that it will not kick out the other session. (Even though that seems sort of backwards from what you'd expect)
The gateway passes complete:true. (From gateway logs)
post={"username":"XXXX","machineId":"12349","compete":true}
Programmatic workarounds here? I think the only choices are:
The text was updated successfully, but these errors were encountered: