Closed nemozny closed 1 year ago
I cannot reproduce this reliably. Now the 1025 gateway is working alongside 1019. This is driving me crazy. I will give this some more testing and close it if it proves erratic.
Ok, I am experiencing this error again. Incidentally after hours, so it might be related. The connection worked fine over the day, but not outside RTH. I have tracked the problem to be caused by this: ib.py line 1786
# the request for executions must come after all orders are in
await asyncio.wait_for(self.reqExecutionsAsync(), timeout)
This is causing the timeout that kills the connection. Commenting out this line fixes the problem.
But how come your Github file ib.py looks differently?
# the request for executions must come after all orders are in
try:
await asyncio.wait_for(self.reqExecutionsAsync(), timeout)
except asyncio.TimeoutError:
msg = 'executions request timed out'
errors.append(msg)
self._logger.error(msg)
My package comes from pip. Am I missing something? The file was changed since the last pip package on Jul 2, 2023? I need to check if your bleeding edge Github repo fixed my problem. Quick patch showed it did not.
This is a regression in TWS that is supposed to be fixed in recent versions. I can't reproduce it with TWS 1025. The code in the git repo bypasses the problem somewhat when connecting but it's not a fix, it's up to IB to fix it on their end.
Also see: https://groups.io/g/twsapi/message/51354 https://groups.io/g/insync/topic/99997016#9153
Thanks for info!
I was experiencing the error just now on 1025 and during RTH, contrary to my previous beliefs. Your workaround in this repo worked, thanks!
Today is 2023-09-18 hour 14, connecting port 7777
executions request timed out
OrderId is: 3
Connected. Current orderId is: 3
You need to manually set timeout this way : ib.connect('127.0.0.1', 7497, clientId=1, timeout=1000)
Update before I actually posted this: The connection works with stable gateway 1019! But not any "latest" version I posted below. I have updated the title. I also needed to pass "clientId=0"/or try and remove it:
1019 also produced the "This event loop is already running" error, but managed to connect. I can reliably reproduce the below on 1023, 1024 and 1025.
------ Original text follows
I am using ib_insync with the paper gateway for a few years, to pull live market data through the paper account. No issues whatsoever. Now I want to hookup ib_insync to my live gateway, to do some position monitoring. However I am constantly getting timeout errors.
I am running through IBC, I fire up the gateway, enter my 2FA and then I am trying to connect via Python.
I didn't want to comment on your earlier thread https://github.com/erdewit/ib_insync/issues/386 , but I do have an unused "sister" account, not a sub account. I created it long time ago and never used.
ib-insync==0.9.86, running Debian on Raspberry Pi, but having the same issue on regular Intel too. I have tried 1023, 1024 and now 1025. API not read-only, download updates on connect, etc.
I have changed my account ID.
The gateway itself logs the same as you see above (ends with "7,3,2,0....."), "client connected" blinks green there and then disconnects.
Strangely:
Let me know if you need anything from me.
This is a gateway log, level = Info.
I don't think this is a port blocking issue.
Huh, I haven't noticed before, but the connection now starts with