Streaming API with Jetty Http Client(Java)


#1

I’m using Jetty Http Client(Java) to interact with Twitter streaming API(https://stream.twitter.com/1.1/statuses/filter.json). I always get “early EOF” excetption:
org.eclipse.jetty.io.EofException: early EOF
at org.eclipse.jetty.client.AbstractHttpConnection$Handler.earlyEOF(AbstractHttpConnection.java:352)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:323)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.client.AsyncHttpConnection.handle(AsyncHttpConnection.java:135)
at org.eclipse.jetty.io.nio.SslConnection.handle(SslConnection.java:196)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)

I saw Twitter recommends to use Apache Http Client to implement the streaming.

Some HTTP client libraries only return the response body after the connection has been closed by the server. These clients will not work for accessing the Streaming API. You must use an HTTP client that will return response data incrementally. Most robust HTTP client libraries will provide this functionality. The Apache HttpClient will handle this use case, for example.

So is there anyone using Jetty client to implement the streaming? I don’t think there should be a problem with Jetty client because Jetty can read the data incrementally…