Skip to content
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

How to re-establish market data subscriptions after connection to TWS/Gateway lost #10

Open
clisztian opened this issue May 29, 2024 · 1 comment

Comments

@clisztian
Copy link

I guess this is more of a general question in the direction of the API itself, but suppose that the TWS /Gateway connection is lost (internet outage, TWS crash, whatever), and by some automatic means the TWS is restarted and reinstated. How does one go about regaining the market subscription after reconnect? The obvious approach of
clientSocket.eConnect(....)
and then calling after successful connection (clientSocket.isConnected() is true)
clientSocket.reqRealTimeBars(...)
with a new id does not work. Connection is successful, but it seems any api calls are inactive/dead. I also tried instantiating a new reader = new EReader(clientSocket..) but that does nothing either.
Would you happen to have any insights on this?
Thanks for you help!

@medovarszki
Copy link
Owner

Hi @clisztian!
In cases like this, I would restart the whole application instead of handling the issue programmatically. The outage itself is an infrastructure issue, so I would handle it like that and create some kind of monitoring tool which restarts the service when the connection is reestablished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants