I'm using EventMachine + em-http-request to request Twitter streaming API. It works perfectly, but now I would like to get it error proof.
What would be the best way to detect that the connection is stalled? (in order to try an auto-reconnect).
I have a temporary solution: each time I receive a new chunk from the stream method, I save the current timestamp. A PeriodicTimer is checking this timestamp and issues a reconnection whenever the last-timestamp is more than 30secs old. The issue with this solution is that it makes no difference between a stalled connection and a working connection with no content.
Thanks for your help.