Detected close of SSE #190
|
Hi. Just trying WatsonWebserver. We use SSE quite a lot for pushing events and they stay open indefinitely on the server side (i.e. not just sending a file then closing like the SSE example in the docs). I'm relying on the connection closing from the client side but I can't see how to detect that. I did a quick test by implementing an SSE handler and connecting to it using a browser. I see the data appearing in the browser OK but when I close the browser I don't get notified on the service side. The cancellation token on HttpContextBase doesn't get cancelled and there are no exceptions passed to the exception handler callback on the route. Any help greatly appreciated. Thanks. |
Replies: 1 comment
|
To answer my own question... I've realised that the SendEvent method will return a bool to indicate success and this will return false when attempting to write data after the client has disconnected. So as long as we have a regular heartbeat message we can detect disconnect on a failed write. |
To answer my own question... I've realised that the SendEvent method will return a bool to indicate success and this will return false when attempting to write data after the client has disconnected. So as long as we have a regular heartbeat message we can detect disconnect on a failed write.