Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
IB_INSYNC API timeout
Post Body

When I try to connect to the TWS API using

'''

util.logToConsole('DEBUG')

ib = IB()

ib.connect('127.0.0.1', 7456, clientId=1)

'''

every other time I get below error and it's so frustrating -

*

2024-11-11 20:46:46,809 ib_insync.client INFO Connecting to 127.0.0.1:7456 with clientId 1...

2024-11-11 20:46:46,812 ib_insync.client INFO Connected

2024-11-11 20:46:46,926 ib_insync.client DEBUG <<< 176,20241111 20:47:45 EST

2024-11-11 20:46:46,927 ib_insync.client DEBUG >>> 71,2,1,

2024-11-11 20:46:46,928 ib_insync.client INFO Logged on to server version 176

2024-11-11 20:46:46,946 ib_insync.client DEBUG <<< 9,1,4649

2024-11-11 20:46:46,958 ib_insync.client DEBUG <<< 15,1,U11493298,U14665191,U14703433,

2024-11-11 20:46:46,959 ib_insync.client INFO API connection ready

2024-11-11 20:46:46,960 ib_insync.client DEBUG >>> 61,1

2024-11-11 20:46:46,961 ib_insync.client DEBUG >>> 5,1

2024-11-11 20:46:46,962 ib_insync.client DEBUG >>> 99,0

2024-11-11 20:46:46,963 ib_insync.client DEBUG >>> 76,1,4649,U11493298,,0

2024-11-11 20:46:46,964 ib_insync.client DEBUG >>> 76,1,4650,U14665191,,0

2024-11-11 20:46:46,966 ib_insync.client DEBUG >>> 76,1,4651,U14703433,,0

2024-11-11 20:46:46,972 ib_insync.client DEBUG <<< 4,2,-1,2104,Market data farm connection is OK:usfarm.nj,

2024-11-11 20:46:46,973 ib_insync.wrapper INFO Warning 2104, reqId -1: Market data farm connection is OK:usfarm.nj

2024-11-11 20:46:46,974 ib_insync.client DEBUG <<< 4,2,-1,2104,Market data farm connection is OK:usfuture,

2024-11-11 20:46:46,975 ib_insync.wrapper INFO Warning 2104, reqId -1: Market data farm connection is OK:usfuture

2024-11-11 20:46:46,977 ib_insync.client DEBUG <<< 4,2,-1,2104,Market data farm connection is OK:cashfarm,

2024-11-11 20:46:46,977 ib_insync.wrapper INFO Warning 2104, reqId -1: Market data farm connection is OK:cashfarm

2024-11-11 20:46:46,978 ib_insync.client DEBUG <<< 4,2,-1,2104,Market data farm connection is OK:cafarm,

2024-11-11 20:46:46,979 ib_insync.wrapper INFO Warning 2104, reqId -1: Market data farm connection is OK:cafarm

2024-11-11 20:46:46,980 ib_insync.client DEBUG <<< 4,2,-1,2104,Market data farm connection is OK:usopt,

2024-11-11 20:46:46,981 ib_insync.wrapper INFO Warning 2104, reqId -1: Market data farm connection is OK:usopt

2024-11-11 20:46:46,983 ib_insync.client DEBUG <<< 4,2,-1,2104,Market data farm connection is OK:usfarm,

...

2024-11-11 20:46:47,747 ib_insync.client DEBUG <<< 74,1,4651

2024-11-11 20:46:47,749 ib_insync.client DEBUG >>> 7,3,4652,0,,,,,,

2024-11-11 20:46:51,759 ib_insync.ib INFO Disconnecting from 127.0.0.1:7456, 157 B sent in 9 messages, 26.7 kB received in 449 messages, session time 4.95 s.

2024-11-11 20:46:51,760 ib_insync.client INFO Disconnecting

*

I see many posts related to it everywhere but no solution. Do any of you found a workaround or is there any robust way to connect to TWS API and maintain persistency in the connection.

Comments

Edwald died and ib_insync has been archived.

I've been using ib_async without this issue

https://github.com/ib-api-reloaded/ib_async

my code was using different clientIds (I randomized it), I don't recall why... but I recently set it to 0, needed to retrieve manually entered orders too ( https://www.interactivebrokers.com/campus/ibkr-api-page/twsapi-doc/#request-active-orders )

Author
Account Strength
80%
Account Age
7 years
Verified Email
Yes
Verified Flair
No
Total Karma
2
Link Karma
1
Comment Karma
1
Profile updated: 1 day ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 weeks ago