Question

I have a web site which uses a Long Poll to wait for the server to finish processing some data. However, a timeout might occur or the user might close his browser, yet the server is continuously processing it's data.
I want the server to stop processing data as soon as the Long Poll connection is broken. There's no client who will receive the data so there's no use for this long process to continue running... How to do this?

The server is working on adding files to a ZIP archive, which takes some time since these are reasonable big files. Once it's done, it will send the final ZIP file and close the connection. But if the client disconnected before the task is finished, the server should stop it's work and discard everything again...

Était-ce utile?

La solution

You should consider using he SignalR framework. It offers very comfortable events like OnConnect() and OnDisconnect(). Under the hood it works with

  • WebSockets
  • Server Sent Events
  • Forever Frame
  • Long polling

It uses whatever is available with the given environment, starting with WebSockets.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top