blaze icon indicating copy to clipboard operation
blaze copied to clipboard

Handling client connection loss when streaming

Open sebastianvoss opened this issue 6 years ago • 0 comments

I'm trying to use a Server-Sent-Event endpoint. This is like a unidirectional web-socket where only the server can send data to the client. As there can be longer periods of time where no data is being sent by the server I'm disabling the idle and request timeouts:

BlazeClientBuilder[IO](ec)
      .withIdleTimeout(Duration.Undefined)
      .withRequestTimeout(Duration.Undefined)
      .resource
      .use { client =>
        client.stream(r).flatMap(_.body.through(ServerSentEvent.decoder))
}

It works fine but this code does not handle connection loss of the client (it just keeps running as if nothing has happened). I would expect that the stream terminates when the client loses the connection to the server. Is this a bug or am I using it in the wrong way?

sebastianvoss avatar Nov 02 '19 15:11 sebastianvoss