Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jaxrs-dev] EventSouce reconnect

Here's the issue : https://github.com/eclipse-ee4j/jaxrs-api/issues/599



On Thu, Mar 15, 2018 at 10:57 PM, Santiago Pericas-Geertsen <Santiago.PericasGeertsen@xxxxxxxxxx> wrote:
Jim,

 I think we definitely need a clarification, and in addition, perhaps even better control over re-connects. The Javadoc for SseEventSource talks about “connection loss” in the context of re-connects. I can see how this could be open to interpretation, which is proven by your experiments with different implementations.

 I’m not sure it makes sense to always reconnect when a connection is gracefully closed (but I think you’re correct about the spec and the browser behavior). We could potentially extend SseEventSource.Builder to accept a re-connect policy such as Always, OnError and Never. 
 
 Could you file an issue for this?

— Santiago


On Mar 14, 2018, at 10:53 PM, Jim Ma <ema@xxxxxxxxxx> wrote:

Santiago, 
From https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events (section 9.2.3), it looks EventSource _javascript_ will always reconnect whether the connection is gracefully closed or unexpectedly.  I think this is why the browser's event source always reconnect after event sink is closed.
If jaxrs EventSource reconnection only happens for unexpected connection close which is different from html5 _javascript_ api, it would be better to add some documentation to clarify this. WDYT ?
Thanks,
Jim 


On Wed, Mar 14, 2018 at 10:24 PM, Santiago Pericas-Geertsen <santiago.pericasgeertsen@oracle.com> wrote:
Jim,

 I think automatic re-connections should only happen if connections are lost, i.e. abruptly interrupted rather than gracefully terminated. 

 If Jersey is not doing that, it is either a bug or a condition in which it is unable to distinguish abrupt vs. graceful termination (I recall there were some issues when Jersey uses HttpUrlConnection, which is its default connector).

— Santiago

On Mar 14, 2018, at 5:44 AM, Jim Ma <ema@xxxxxxxxxx> wrote:

 CXF 3.2.2 stops reconnecting after event sink is gracefully closed as jaxrs spec says, but Jersey 2.26  keeps reconnecting.  

On Wed, Mar 14, 2018 at 4:54 PM, Markus KARG <markus@xxxxxxxxxxxxxxx> wrote:

I think we should look at what the JAX-RS implementations actually do. What is Jersey doing? What is CXF doing? And then look if they all behave the same and specify that as the Default. It might be a good idea to specify an additional policy Annotation in case the implementations behave differently.

 

Von: Jim Ma
Gesendet: Mittwoch, 14. März 2018 05:49
An: jaxrs developer discussions
Betreff: [jaxrs-dev] EventSouce reconnect

 

When the EventSink is closed after send several events with the following resource method , should EventSource reconnect automatically? 

   @GET

   @Path("/closeAfterSent")

   @Produces(MediaType.SERVER_SENT_EVENTS)

   public void eventStream(@Context SseEventSink eventSink, @Context Sse sse) throws Exception {

      System.out.println("entering eventStream()");

      ExecutorService pool = Executors.newCachedThreadPool();

      OutboundSseEvent.Builder builder = sse.newEventBuilder().mediaType(MediaType.APPLICATION_XML_TYPE);

      pool.execute(new Thread()

      {

         public void run()

         {

            try (SseEventSink sink = eventSink) 

            {

               System.out.println("sending 3 events");

               eventSink.send(builder.data("thing1").build());

               eventSink.send(builder.data("thing2").build());

               eventSink.send(builder.data("thing3").build());

               System.out.println("sent 3 events");

            }

         }

      });

   }

 

In EventSource api doc, it says EventSource will reconnect after connection loss or missing events. Should we add some clarification for this situation ?  I know Firefox or Chrome's EventSource will automatically reconnect after event sink is closed.  Should jaxrs' EventSource do the same ?

 

Thanks,

Jim

 


_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev


_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev


_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev


_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev


_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev



Back to the top