Intensive keep-alive requests

Aug 25, 2014 at 8:26 AM

Sometimes my twitter streaming callback starts getting too much keep-alive messages, and stops getting tweets. When i restart my program, it is fixed.

Does anyone know anything about this situation ?

Thaks a lot.
Aug 26, 2014 at 2:24 AM

Those keep-alive messages are coming from the Twitter API. Instead of manually restarting your program, try just restarting the stream:
  1. Capture a reference to the streamContent that you get in the callback.
  2. When keep-alives exceed a reasonable threshold, call Close on the streamContent. Keep-alives should arrive around every 30 seconds of inactivity - to let you know that the stream is still open.
  3. Create a new TwitterContext instance.
  4. Re-start the stream.
To prevent missing any tweets, keep track of the last tweet ID received. After you restart the stream, get the first Tweet ID. Then you can use the REST API to query for the missing tweets.

Aug 26, 2014 at 4:43 AM
Hi JoeMayo,

Thanks a lot again for your help,

it was very helpful.