Client side error on Autentication failure?
Opened this issue · 1 comments
skatoch27 commented
Given this:
function onAuthorizeFail(data, message, error, accept){
console.log('failed connection to socket.io:', message);
if(error)
accept(new Error(message));
}
How to handle this on the client side?
The documentation mentions:
// If you use socket.io@1.X the callback looks different
// If you don't want to accept the connection
if(error)
accept(new Error(message));
**// this error will be sent to the user as a special error-package
// see: http://socket.io/docs/client-api/#socket > error-object**
But its not clear what to do on the client side. For example none of the following are triggered:
socket.on('error',function(data) {
console.log('error...',data);
});
socket.on('connect_error',function(data) {
console.log('connect error...',data);
});
skatoch27 commented
Updating upon further tests, onAuthorizeFail gets called with error==false.
So removing the if(error) condition triggers "packet" (not connect_error) event:
function onAuthorizeFail(data, message, error, accept){
console.log('failed connection to socket.io:', message);
accept(new Error(message));
}
So what is the purpose of "error"?
Edit: packet is triggered instead of connect_error