-
-
Notifications
You must be signed in to change notification settings - Fork 588
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
Client is always accepted for undeclared namespaces #822
Comments
Yes, I believe your analysis is correct. The server should not accept a connection for a namespace it does not know about.
I don't understand what you mean here. The current version of the Socket.IO protocol does not treat the |
@miguelgrinberg Thanks!
Full disclosure, I spent a good amount of time looking for other reasons why I was not getting There is a high probability my understanding is incorrect and I defer to your understanding of the protocol: I have not read myself into it. With this said, if you want me to PR on this let me know, but I'm not clear on what the appropriate fix should be. Perhaps a |
This used to be true, so I'm sure there are references to this behavior in old issues, but it is not done anymore.
I'm not sure what behavior we want for this use case. Probably same as if the connect handler returns |
Actually this fix was the thing that broke the functionality of my service yesterday after upgrading Socketio to v5.7.0. After this fix I have to keep the list of all possible namespaces on the server to let them connect. Or monkeypatch the connection handler to allow all connections. Can we have an option to allow non-declared namespaces to connect? |
@ba1dr this was really an oversight, it does not really make much sense to accept unknown namespaces, the best default is to reject them. To change this default, all you need to do is add a connect handler for these namespaces. The handle doesn't need to do anything, just by existing the default will change to allow those connections. |
@miguelgrinberg I understand why this has been fixed. Indeed, to prevent the server of keeping pool of potentially wrong/useless connections better to reject them in most cases. But in my case this is an internal server and all clients are trusted. |
Okay, I added |
Yes, I think this will help. Thank you for your efforts! |
This is now released in v5.7.1. |
Describe the bug
This issue is manifesting itself through flask-socketio, but I believe the source of the issue belongs here. When a client connects using a namespace that is not declared, the namespace is simply added and the client connects with no ability to execute code against the connection in order to reject it.
The end result is that it is possible to pollute the connection pool with phantom clients, and the server cannot detect when new clients connect.
The source of issue I believe is here:
python-socketio/src/socketio/base_manager.py
Line 119 in 3bd1357
To Reproduce
always_connect
value.Expected behavior
One of:
/
namespaceconnect
, with relevant details on the namespace attempted to connect to.In all cases, it is also expected that the
/
namespaceconnect
event fires, which is also not occurring.Logs
Additional context
If this is not intended behaviour, a possible easy solution is to add an else to to the if else if block of Server._trigger_event
If more detail is required, please let me know!
The text was updated successfully, but these errors were encountered: