ib_async
ib_async copied to clipboard
Api connection failed
Hi,
I installed ib_async 1.0.3 and use ib gateway 10.30.1, when I tried to connect to the gateway, I found the following error:
Python 3.12.7 | packaged by Anaconda, Inc. | (main, Oct 4 2024, 08:22:19) [Clang 14.0.6 ] on darwin Type "help", "copyright", "credits" or "license" for more information.
from ib_async import * util.logToConsole('DEBUG') ib = IB() ib.connect('127.0.0.1', 4002, clientId=123, timeout=10) 2025-04-25 15:23:55,553 ib_async.client INFO Connecting to 127.0.0.1:4002 with clientId 123... 2025-04-25 15:23:55,554 ib_async.client INFO Connected 2025-04-25 15:23:55,621 ib_async.client DEBUG <<< 178,20250425 15:23:54 EST 2025-04-25 15:23:55,621 ib_async.client DEBUG >>> 71,2,123, 2025-04-25 15:23:55,622 ib_async.client INFO Logged on to server version 178 2025-04-25 15:23:56,124 ib_async.client ERROR Peer closed connection. clientId 123 already in use? 2025-04-25 15:24:05,556 ib_async.client INFO Disconnecting 2025-04-25 15:24:05,556 ib_async.client ERROR API connection failed: TimeoutError()
I'm sure the gateway is running and port 4002 is listened, the clientid is also unique, but I still get this error. Does anyone encounter this before?
Thanks
Try removing the timeout, so just:
ib.connect('127.0.0.1', 4002, clientId=123)