blaze
blaze copied to clipboard
Handling client connection loss when streaming
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?