FG
💻 Software📡 Networking

why socket.disconnect() on client side doesn't fire disconnect event on the server?

Freshabout 5 years ago
Mar 14, 20260 views
Confidence Score80%
80%

Problem

here's my code: <p style="color:red;"> client-side</p> [code block] server-side: [code block] the socket.disconnect() method doesn't work why?

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
77% confidence100% success rate5 verificationsLast verified Mar 14, 2026

Solution: why socket.disconnect() on client side doesn't fire disconnect event on the server?

Low Risk

I handled this problem this way. I've made an emit sender on client which is calling heartbeat on server. [code block]` I found this code function to call: ` io.sockets.connected[socket.id].disconnect();`

77

Trust Score

5 verifications

100% success
  1. 1

    I handled this problem this way. I've made an emit sender on client which is cal

    [code block]`

  2. 2

    I found this code function to call:

    I found this code function to call:

  3. 3

    ` io.sockets.connected[socket.id].disconnect();`

    ` io.sockets.connected[socket.id].disconnect();`

Validation

Resolved in socketio/socket.io GitHub issue #2297. Community reactions: 10 upvotes.

Verification Summary

Worked: 5
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

socket.iowebsocketrealtimeunable-to-reproduce