vertx.createHttpServer().requestHandler(request -> {
final HttpServerResponse response = request.response();
response.setChunked(true);
response.headers().add("Content-Type", "text/event-stream;charset=UTF-8");
response.headers().add("Connection", "keep-alive");
vertx.eventBus().registerHandler("events", msg -> {
response.write("event: message\ndata: " + msg.body() + "\n\n");
});
}).listen(8080);The problem seems to be, that the response isn't flushed to the browser. Therefore the only possiblity to have a successful SSE is by occassionally closing the connection.
My inital thought was that I'm probably missing something.
Could somebody please help.
Regrads,
Christoph
Hi,
I tried doing SSE with vert.x and found it uncomfortable:
vertx.createHttpServer().requestHandler(request -> { final HttpServerResponse response = request.response(); response.setChunked(true); response.headers().add("Content-Type", "text/event-stream;charset=UTF-8"); response.headers().add("Connection", "keep-alive"); vertx.eventBus().registerHandler("events", msg -> { response.write("event: message\ndata: " + msg.body() + "\n\n"); }); }).listen(8080);The problem seems to be, that the response isn't flushed to the browser.
Therefore the only possiblity to have a successful SSE is by occassionally closing the connection.My inital thought was that I'm probably missing something.Could somebody please help.Regrads,Christoph
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
vertx.createHttpServer().requestHandler(request -> {
EventTarget target = new VertXEventTarget(request); vertx.eventBus().registerHandler("events", msg -> { target.("message", msg.body());
});
}).listen(8080);--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/3ae759a3-f223-4463-bc40-cfcadfaf381e%40googlegroups.com.