Streaming tweet received only after second one is posted


#1

I’m using the Streaming API to filter tweets by hashtag. I noticed an interesting occurrence. When I post a single tweet, the script listening to the streaming API doesn’t receive it. However, when I post another tweet that also matches the filter, the first tweet is received, but not the second one. If there is no second tweet, the first tweet is received quite a bit later (about an hour).

Is this the expected behavior? Am I missing a setting that forces the API to always hold on to one tweet or something?!

Thanks!


#2

I’ve seen this behavior and turned out to be due to an unflushed read buffer. This can happen especially if you’re decoding a gzipped stream as it can be difficult to get enough data to decode.

In fact, there’s a workaround for Java-based clients if you’re interested:
https://dev.twitter.com/docs/streaming-apis/processing#Gzip_and_Java