Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-1839

SseEventSourceImpl unexpected behavior

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 4.0.0.Beta2, 3.5.0.Final
    • jaxrs

    Description

      SseEventSourceImpl does not follow full or part of the following assertions:

      We are expecting the SseEventSource connection to fail when a response other than 200 is received.
      In this case, it must be closed and must notify:
      - error listeners since it is an unrecoverable error.
      - completion listener since no further events will be received.
      
      We are expecting the SseEventSource connection to fail when a 200 response with a Content-Type header unspecified
      or other than text/event-stream is received.
      In this case, it must be closed and must notify:
      - error listeners since it is an unrecoverable error.
      - completion listener since no further events will be received.
      
      We are expecting the SseEventSource to close itself and not try to reconnect on a 204 response.
      In this case, it must be closed and must notify:
      - completion listener since no further events will be received.
      Error listeners are not notified in this case since it is a normal behavior.
      
      We are expecting the SseEventSource to reconnect when the connection is closed (gracefully or not).
      In this case, no error listener will be notified since it is not an unrecoverable error since we are trying to reconnect.
      Completion listener will not be notified neither since other events will be received.
      

      Those asserytions are based upon SSE specs an can be easily tested using new EventSource(...) in Chorme or any browser:

      https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events-intro

      Clients will reconnect if the connection is closed; a client can be told to stop reconnecting using the
      HTTP 204 No Content response code.
      

      https://html.spec.whatwg.org/multipage/server-sent-events.html#sse-processing-model

      HTTP 200 OK responses that have a Content-Type specifying an unsupported type, or that have no
      Content-Type at all, must cause the user agent to fail the connection.
      
      Any other HTTP response code not listed here, as well as the cancelation of the fetch algorithm by the
      user agent (e.g. in response to window.stop() or the user canceling the network connection manually) must cause
      the user agent to fail the connection.
      
       Once the user agent has failed the connection, it does not attempt to reconnect!
      

      So in order stop the reconnecting mech we can either do it from the client by closing the SseEventSource,
      or on the server side by responding with a non "text/event-stream" Content-Type or return an HTTP status other than 200 OK, idealy a 204.

      Attachments

        Activity

          People

            rhn-engineering-ema Jim Ma
            nicones Nicolas NESMON
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: