-
-
Notifications
You must be signed in to change notification settings - Fork 574
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
Error in client after server has rejected connection #504
Comments
What did you expect should happen? The error that you are getting is a |
I expected the following:
After adapting the handlers in the client the following way: @sio.on('result')
def on_match_result(json):
global message
message = json
logger.info(f'Server responded to the connection attempt with the following message to "result": {message}')
server_response_received.set()
@sio.event
def connect_error(msg):
global message
message = msg
logger.info(f'Server responded to the connection attempt with the connect_error: {message}')
server_response_received.set() I get the following output on the serverside:
This way the client does not process the result-event. |
@MaiKitty you can't emit and then reject the connection, that's not how things work. A rejected connection is never established, there is no transport set up on which an event can travel. Take a look at the |
I have already set |
Hmm. Okay, sorry, I missed that. I need to check if something broke with regards to the always_connect option then. |
Thank you :) |
Quick update. It appears that the Then, I recently fixed another problem with rejected connections when So the plan is for me to a) make sure a rejected connection does not return a 401 error when |
Thanks for the update! The plan sounds good to me. Can you recommend any alternatives in the mean time? |
The alternative is to use the normal method for rejecting connections, which is to not emit anything if the connection is going to be rejected. I really never intended to support what you are trying to do, really. After looking at this and how complicated it would be to implement I'm actually thinking that I may end up documenting this as a limitation. So basically you will be able to call |
Alright, thank you! |
I am trying to accomplish the following:
In case of invalid authentication by the client the socketio server should emit an event and disconnect the client.
However I get the following error on the client side:
Traceback (most recent call last): File "client.py", line 35, in <module> sio.connect("http://localhost:8080") File "C:\Users\Mai\.virtualenvs\python_socketio_auth-571J5SCS\lib\site-packages\socketio\client.py", line 282, in connect six.raise_from(exceptions.ConnectionError(exc.args[0]), None) File "<string>", line 3, in raise_from socketio.exceptions.ConnectionError: Unexpected status code 401 in server response
After having found this particular post I am aware that
there are issues with the server rejecting the connection.
However, I have already updated python-socketio to the newest version where you
improved the handling of rejected connections.
The error above occurs using the newest version.
Below I provide the log-output of the server and code to reproduce this error
Am I doing something wrong or is this an issue with python-socketio?
The text was updated successfully, but these errors were encountered: