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

SSE should cancel ReactiveStreams subscription on connection close

XMLWordPrintable

    • User Experience
    • Undefined

      Given a JAX-RS resource method that returns a reactive stream (with an output media type of text/event-stream), each connection is associated with a corresponding Subscription.  If a client disconnects by resetting the connection, the Subscription stays around until the next time  SseEventOutputImpl#internalFlushResponseToClient is called even though the HTTP connection is closed immediately.  If the connection is mostly idle, this can cause dead Subscriptions to pile up, resulting in a memory leak.

      Sending artificial keepalive events to clients is a possible workaround, but in my opinion, avoiding the problem in the first place would be nicer.

      I haven't checked other back ends, but at least the Vert.x back end appears capable of propagating connection close events upwards as they happen (via io.vertx.core.http.HttpServerResponse#closeHandler, for instance).  It would be nice if RESTEasy freed Subscriptions and other resources promptly in such cases.

              Unassigned Unassigned
              login@mail.matthias.benkard.de Matthias Benkard (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: