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

SseEventSourceImpl.open() should be blocking until the server initial response

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 3.6.0.Final, 4.0.0.Beta4
    • 4.0.0.Beta2, 3.5.0.Final
    • jaxrs

    Description

      • Accoring to the java Sse spec, the SseEventSourceImpl.open() is supposed to be a sync/blocking method until the connection is established.

      The problem with the current impl is that if the Sse connection is not established within 30 seconds, the open() method will not block any longer and then just becomes async. The user is not warn about any kind of timeout exception. More the http connection is not even killed.

      • According to both java SSE and HTML5 specs:
      The initial SSE response, may only include the HTTP headers
      

      So a legal response to a SSE request can be:

      1 - 200 OK with Content-type header set to text/event-stream without no response body in this initial reponse

      2 - Then later since the connection remains open, the first SSE event is sent.

      So according to the way SseEventSourceImpl.open() is implemented :

         public void open(String lastEventId)
         {
            ...
            handler.awaitConnected();
          }
      

      The countdownLatch will be counted down on receiving the first SseEvent instead of being counted down when the connection is established, I mean on receiving the initial HTTP response code

      (This is due to the fact that eventInput = request.get(SseEventInputImpl.class); in EventHandler.run() will wait for a response body to be available before returning.)

      Attachments

        Activity

          People

            rhn-support-asoldano Alessio Soldano
            nicones Nicolas NESMON
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: