How do I detect client disconnect from a long poll to a Spring endpoint

48 views Asked by At

I'm trying to call an endpoint in a Spring application thats using @RestController and @GetMapping. It's doing a long running loop then sending back a ResponseEntity.ok(). The problem I'm encountering is that if the client cancels/disconnects from the long poll, the endpoint will still return as if nothing has changed. How do I detect client disconnects using this framework?

I have tried using DeferredResults, ResponseBodyEmitters and SSEEmitters but none achieve what I want. Ultimatley I want to be able to catch an exception when a client disconnects during a long poll, but in the short term I would just like to be able to see some kind of logging for when a client disconnects.

0

There are 0 answers