-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Re-connect after TWS restart not working properly #195
Comments
Thanks for reporting with much details. |
Your use case is passing with latest changes. |
Hello, I tried multiple TWS restarts even with 1ms interval and the problem seems to be fixed now, it does not return decoding error anymore and also does not stack connections. Great job! |
@rylorin Hello again, by this change a new "minibug" appeared. The API trigger EventName.disconnected always when I send ib.connect() and API is not connected. So in my case when I am restarting TWS or I turn it off, my reconnect interval calls ib.connect() every 10 seconds and when TWS is off it trigger EventName.disconnected every 10 seconds as well. However it is not bug at all, I just wanted to let you know. let ibApiConnected = false
ib.on(EventName.connected, () => {
ibApiConnected = true
console.log("IB API connected")
})
ib.on(EventName.disconnected, () => {
if (ibApiConnected) {
ibApiConnected = false
console.log("IB API disconnected")
}
}) |
Thanks for your feedback. |
Hi, I found a very strange thing in re-connection. I am using interval for re-connections, however when I restart TWS (to simulate auto-restart) sometimes it hit a very strange point (bad timing) and the whole connections starts messing up and I am unable to reconnect until I restart the script. It creates bugged connection in TWS which is somehow disconnected (but not disconnected) exactly in one minute after this error message appears "Decoding error on undefined: unprocessed data left on queue..." and then the infinite loop of re-connection begin because in TWS it is already connected on the same port so it is unable to connect.
By the way, I also tried different time for the interval, like 10 seconds or one minute, it happens less often because its harder to hit the point, but it still happens.
Please check attached video please, it explains everything. I needed to upload it external as I am unable to upload more than 10mb file so here is the link: https://mega.nz/file/koMBUZSL#F1xQ09isob8gSLckJhH0WUzFX-sqyUz3yVw_XDeAP1E (the first TWS restart on the video was fine, the second time what I described above happened)
Also here you can find whole output of everything you can see in the video:
debug.log
Here is my test code:
Thanks for checking it out. Have a nice day.
The text was updated successfully, but these errors were encountered: