I am developing a data capture and trading automation tool, which uses long-lived connections with both the trade and market data servers. Occasionally my connection gets dropped—without a close frame or event message—for a couple reasons I’ve identified:
- Failing to send heartbeats often enough
- Sending different requests with an identical integer
- Sending multiple requests too rapidly
- Maintaining a connection for over 24 hours
Sometimes one (or both) connection drops without being obviously related to the above causes. My socket handlers check connectivity after an EOF by pinging the WebSocket server and 184.108.40.206, but that is almost never the issue. At this point I’m concerned it’s a task scheduling issue that will be difficult to debug with multithreading.
Has anyone else stumbled on other avoidable causes for connection loss and/or end-of-file?