Hi,
I've tried using Jersey Server Sent Events with jetty 8.15 and everything seems to work quite nicely... as long as I use the SelectChannelConnector. If I use the SocketConnector, I get this kind of error logged on the console and the SSE client gets an error:
2014-05-30 22:02:40.736:WARN:oejsb.SocketConnector:handle failed?
java.lang.NullPointerException
at org.eclipse.jetty.http.HttpGenerator.prepareBuffers(HttpGenerator.java:933)
at org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:811)
at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:79)
at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:680)
Exception in thread "Thread-13" java.lang.RuntimeException: Error when writing the event.
at sample.jersey.HelloResourceService$1.run(HelloResourceService.java:53)
at java.lang.Thread.run(Thread.java:680)
Caused by: org.eclipse.jetty.io.EofException
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:142)
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:117)
at org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:214)
at org.glassfish.jersey.server.ChunkedOutput$1.call(ChunkedOutput.java:237)
at org.glassfish.jersey.server.ChunkedOutput$1.call(ChunkedOutput.java:192)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:242)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:346)
at org.glassfish.jersey.server.ChunkedOutput.flushQueue(ChunkedOutput.java:192)
at org.glassfish.jersey.server.ChunkedOutput.write(ChunkedOutput.java:182)
at sample.jersey.HelloResourceService$1.run(HelloResourceService.java:50)
... 1 more
Here's a simple maven project that reproduces the problem:
It contains a simple Main class that starts a sample webap on top of a server configured with both connectors, the NIO one listening on 9999 and the BIO one on 8888. When I hit
http://localhost:9999/hello/ I see the events appearing, but when I try
http://localhost:8888/hello/ fails.
Could there be a bug in the BIO connector?
Thanks,
Ludovic