I am using node.js for long held connections. I want to know how I can detect when the client connection closes (maybe when the user closes the tab). How do I specify a callback for that?
Detecting close of client connect in node.js
|
Other Answer1
Answering my own question - You can detect close of client connection by doing:
|
Other Answer2
Take a look at Socket.io. It supports the following transports with fallbacks in this order:
The benefit is you'll be able to handle a lot more concurrent connections than long polling alone. In addition you'll get a rich set of features like heartbeats and disconnects.
|
Relate
- how to connect node.js rest client with UI [closed]
- Detecting HTTP close using inet
- Detecting client screen resolution
- Benchmark TCP Connect/Close
- Nginx on Windows 7 and detecting Node.js
- detecting notificationbox close event - firefox addons
- How can a Node.js Socket Server know which IP or domain that the client connect to?
- Detecting outlook 2007 client in email
- Detecting aborted client requests with FastCGI
- How to close connection for Node.js http.createClient?
- Can't close a MongoDB connection with Node.js?
- node.js + connect 404 error
- “Cannot GET /” with Connect on Node.js
- “connect EMFILE” error in Node.js
- Node.js failing to connect to MongoDB