Skip to content

Handshake authorization stuck. #1934

Closed
Closed
@EugeneKostrikov

Description

@EugeneKostrikov

Hello,

I'm trying to figure out how to fail authorization correctly. If i callback with error from the middleware the server is getting stuck. Tried both middleware style and io.set('authorization'). The code is as follows.

Client is the same for both scenarios:

        socket = ioClient.connect(options.ioUrl + "/people", {query: query, forceNew: true});
        socket.on('data', function(data){
          console.log(data);
        });
        socket.on('connect', function() {
          callback();
        });
        socket.on('error', function(err){
          callback(err);
        });

Server with io.set

      io.set('authorization', function(handshake, done){
        setTimeout(function(){
          done(null, false);
        }, 100);
      });

Server with middleware

      io.use(function(socket, next){
          setTimeout(function(){
           next(new Error('Auth failed');
          });
    });

It looks like the problem is transport. The state is still opening when i fail the auth. However if i use timeouts, it is writable. The client does not get any event at all.
If i do not fail the auth - connect event fires.
Any idea what is wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions