Skip to content
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

Handshake authorization stuck. #1934

Closed
EugeneKostrikov opened this issue Jan 7, 2015 · 5 comments
Closed

Handshake authorization stuck. #1934

EugeneKostrikov opened this issue Jan 7, 2015 · 5 comments
Milestone

Comments

@EugeneKostrikov
Copy link

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?

@alxyang
Copy link

alxyang commented Jan 10, 2015

Could you perhaps be a bit more specific as to the environment from which you are experiencing this issue? (Browser, Node version, OS, etc.)

I wrote a sample test and was not able to reproduce the issue.
Code for the test is here: https://gist.github.com/aly006/cbc84a57d24744b67a32

Let me know if I am misunderstanding anything.

@peteruithoven
Copy link

@EugeneKostrikov, maybe you're experience this issue: #1888
Since you're trying to connect to a namespace. What happens when you try to connect to the root namespace?
@Aly006, maybe you can try to include a namespace in your sample?

@serhiisol
Copy link
Contributor

serhiisol commented Nov 22, 2016

Experiencing exactly the same problem that @EugeneKostrikov has mentioned.

setTimeout works only when client has really strong connection, otherwise he won't get error event.

Tried with throttling - same result, won't receive error event

Socket.IO - 1.6.0
Chrome - 57.0.2926.0 canary (64-bit)
NodeJS - 7.1.0
OS - macOS Sierra 10.12.1

PS. to fix this issue for now, we can replace engine with uWebSockets (e.g.):

https://github.com/uWebSockets/uWebSockets#i-would-stay-away-from-these-projects

@murrayju
Copy link

See #3089 and #2342. The error is being fired on the default namespace, and not your custom namespace. I don't think it should work this way, but that's the current behavior.

@darrachequesne
Copy link
Member

@darrachequesne darrachequesne added this to the 3.0.0 milestone Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants
@murrayju @peteruithoven @alxyang @EugeneKostrikov @serhiisol @darrachequesne and others