Search code examples
javascriptjerseyserver-sent-eventsjersey-client

Jersey 2.8 SSE registration keeps waiting if more than 5 clients


We are using jersey SSE for pushing events to the client.

We are using the following code to register for an event in the javascript side,

var source = new EventSource(<URL>);
source.onmessage = notifyEvent;

URL ==> on each URL different event registrations will be there which takes care of registering for that event. Eg:

http://localhost:8080/testapp/notification/comment/{userID} ==> used to register for comment notification for a specific user.

http://localhost:8080/testapp/notification/like/{userID} ==> used to register for like event for a specific user

notifyEvent ==> is the method defined which will be called when we receive any event.

The registrations and notifying of the events works perfect, until a client tries to register for 6 events, if its 5 events, registration and notification works perfectly alright.

When we try to register for 6th event, on the server side EventOutput data is returned successfully, but on the client side the jsp file keeps loading.

Why is it hanging exactly at the 6th event registration?

If there are 2 different client application running, each register for 5 events, during such situation all the event notification stuffs(register and notifying) works perfectly fine.


Solution

  • only six connection can be used at any point of time in a browser. that is a limitation in a browser.

    Refer this link for more information SSE(EventSource): why no more than 6 connections?