question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

here’s my code:

client-side

 var socket = io.connect('http://' + serverAddress ,{ reconnection: false, forceNew: true  }  );

 socket.emit('monitorAddedNotify' , { video: sourceVideo , socketId: socket.id});

 socket.on('disconnectThatSoc', function(){
    socket.disconnect();
});

server-side:

  io.on('connection', function (socket) {
    console.log('a user connected');


    socket.on('disconnect', function () {
        console.log('user disconnected');
    });
 });

the socket.disconnect() method doesn’t work why?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:24 (3 by maintainers)

github_iconTop GitHub Comments

116reactions
Ehsan666xcommented, Sep 1, 2019

are you dumb? you are waiting for an emit on client but no emit on server. fuck out of here

18reactions
GlitchBorkcommented, Sep 1, 2019

That’s some real negative energy, Ehsan666x.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - why socket.disconnect() on client side doesn't fire ...
Your use of this inside a far arrow function inside a static method is really, really confusing. The this value will likely be...
Read more >
The Socket instance (client-side)
This event is fired upon disconnection. ... In the first two cases (explicit disconnection), the client will not try to reconnect and you...
Read more >
[Solved]-why socket.disconnect() on client side doesn't fire ...
Coding example for the question why socket.disconnect() on client side doesn't fire disconnect event on the server?-node.js.
Read more >
Can you explain why socket.io disconnect doesn't work?
According to the socket.io docs the disconnect function automatically leaves all rooms. I even checked on the server side, if the disconnect ...
Read more >
Socket.IO, React and Node.js: Going Real-Time
We can listen for a connection event, fire up a function when a new user ... IO client will not be able to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found