xhr.abort on disconnect not sending connection close to server on beforeunload event
Problem
Is any body else running into this issue? Here is the scenario: 1. We are running node/socket.io on a separate server with its own DNS/domainname (Don't ask why) and our application server is on a different host/DNS/domainname. 2. The socket.io.js file is rendered from the node server. 3. When a user navigates away from a page we would like to send a disconnect event to the server from client. (Should be pretty easy right?) 4. Upon debugging we found that on line 3436 in socket.io.js an xhr.abort command is issued which should tell the server to initiate a disconnect event. (But no dice). 5. The disconnect finally fires but not from the unload event, but from the connection timeout. 6. Seems pretty simple, anyone else having these issues? Thanks.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: xhr.abort on disconnect not sending connection close to server on beforeunload event
As much I don't like the solution and was hoping someone would provide a more "elegant" solution, at this time just sending an synchronous disconnect on the window unload event does the trick but that is a definitely a hack job solution.
Trust Score
1 verification
- 1
As much I don't like the solution and was hoping someone would provide a more "e
As much I don't like the solution and was hoping someone would provide a more "elegant" solution, at this time just sending an synchronous disconnect on the window unload event does the trick but that is a definitely a hack job solution.
Validation
Resolved in socketio/socket.io GitHub issue #461. Community reactions: 0 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep