-
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
Problem with disconnect - "client error" #2544
Comments
I had the same issue with v1.4.6, so I rolled back to v1.4.5 in my code, I guess thew new version has some breaking changes |
I have also hit this issue - the client doesn't get the memo that connection is supposed to be closed. Version is 1.4.8 Code to reproduce: var i = 0,
port = 11111,
server = require('socket.io')(port),
client = require('socket.io-client')('http://localhost:' + port);
server.on('connect', function (socket) {
console.log('SERVER :: connect');
socket.on('error', function () {
console.log('SERVER :: error');
});
socket.on('reconnect', function () {
console.log('SERVER :: reconnect');
});
socket.on('disconnect', function () {
console.log('SERVER :: disconnect');
});
socket.on('/ping', function (i) {
console.log('SERVER :: ping ' + i);
if (i > 2) {
throw 'Spanner';
}
socket.emit('/pong', i);
});
});
client.on('connect', function () {
console.log('CLIENT :: connect');
});
client.on('error', function (err) {
console.log('CLIENT :: error');
console.log(err.code, 'in the works');
});
client.on('reconnect', function () {
console.log('CLIENT :: reconnect');
});
client.on('disconnect', function () {
console.log('CLIENT :: disconnect');
});
client.on('/pong', function (i) {
console.log('CLIENT :: pong ' + i);
});
setInterval(function () {
console.log('CLIENT :: socket.connected is ' + client.connected);
client.emit('/ping', i);
i += 1;
}, 1000); Relevant log file portion:
|
So I have done some digging. The repro code above depends on fix for #1880 (introduced in v1.2.1) which adds a try/catch block whereas before the app would crash. This was not a good idea IMO as it hides unexpected exceptions in user code (expected exceptions are for the user to handle). Trigger condition aside, the real issue seems to be that neither Socket.disconnect(), nor Socket.close() is ever called during the error handling process. I suspect this code never worked before, just that it was never triggered. |
That issue was closed automatically. Please check if your issue is fixed with the latest release, and reopen if needed (with a fiddle reproducing the issue if possible). |
Hello,
There is something wrong if connection is closed with reason "client error".
Debug on server side:
socket.io:client client close with reason client error +5s
socket.io:socket closing socket - reason client error +0ms
and only event 'disconnect' is called on server side with reason "client error"
Debug on client side:
log is empty and none event is called on client side ("error", "disconnect" etc...). Client seems to be connected without problem, but only one way communication is working - from client to server. Server is able to receive messages from client, but client receives nothing.
We are using a latest version 1.4.6.
The text was updated successfully, but these errors were encountered: