-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client.disconnect() to force a client to disconnect #47
Comments
It might be interesting to discuss whether it's worth implementing (although it'd be low priority). However, IRC kick/ban is an example of where I wouldn't use such functionality. In those scenarios it's desired to keep the client connected, and just prevent broadcasting of messages of a specific channel. |
Found this when pondering a similar method. I'd like a way to explicitly and cleanly tell a client it is being disconnected for policy reasons, not transport reasons. For instance, authorisation failure. This way, the client knows the connection was established but was disconnected at the host's behest, and need not try fallback transports. Thanks! |
This would indeed be very useful. |
Is client.connection.destroy() a legitimate way to disconnect a client? |
plus1. Would love to have a way to cleanly disconnect a client. :) |
client._onDisconnect(); or seem to do the trick. NOTE: There is an underscore before the "onDisconnect", it just doesn't render in this markdown. |
Also saw someone do it like this (haven't tested it myself though): |
Is this implemented now, or should I use the - method socket.clients[kickedClientId].send({ event: 'disconnect' }); |
What is the "official" way to do this???? |
Please re-open such that we find out what the official way is. |
There is still no solution to this, please reopen to track progress. |
I just discovered this code in client/socket.js: /**
* Kicks client
*
* @api public
*/
Socket.prototype.disconnect = function () {
if (!this.disconnected) {
this.log.info('booting client');
if ('' === this.namespace.name) {
if (this.manager.transports[this.id] && this.manager.transports[this.id].open) {
this.manager.transports[this.id].onForcedDisconnect();
} else {
this.manager.onClientDisconnect(this.id);
this.manager.store.publish('disconnect:' + this.id);
}
} else {
this.packet({type: 'disconnect'});
this.manager.onLeave(this.id, this.namespace.name);
this.$emit('disconnect', 'booted');
}
}
return this;
}; I tried it ( See also issue #795. |
the |
@geniousphp I'm having the same issue |
So why is the issue closed, is it solved? if so how? What is the conclusion? |
I don't know why it's closed, it doesn't works for me and I still use the ugly way to force disconnection. |
Try, |
I think that's what I want. awesome. |
Unfortunately @acidhax his method does not work any more since the 1.0 release |
Is there anyway that upgrade 0.9.16 to 1.X.X smoothly,guys? |
+1 |
Same boat here. This is really important for testing as you want to isolate tests from each other. |
|
My function app triggered repeatedly when device gets the message. Every time my function app socket connection opened.How to close the opened connection forcibly. }; |
11 years...passed :) This is till an issue, can not kick client out or simply tell them to disconnect ! Steve |
@thusinh1969 you can use Reference: https://socket.io/docs/v4/server-api/#socketdisconnectclose |
That will allow to use a custom parser (see #2829).
It would be great to have a disconnect() method on Client instances. This is useful to implement mechanisms such as IRC's kick/ban. Basically there needs to be a way to get rid of abusers.
The text was updated successfully, but these errors were encountered: