Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

Client side error on Autentication failure? #134

Open
skatoch27 opened this issue Apr 5, 2017 · 1 comment
Open

Client side error on Autentication failure? #134

skatoch27 opened this issue Apr 5, 2017 · 1 comment

Comments

@skatoch27
Copy link

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 [email protected] 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
Copy link
Author

skatoch27 commented Apr 5, 2017

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

mef added a commit to mef/passport.socketio that referenced this issue May 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant