-
-
Notifications
You must be signed in to change notification settings - Fork 895
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
why the client can not receive the emit data during connecting? #989
Comments
What do you return |
because i wanna to tell somesthing to the client why i refused the connection before i return False |
Okay, then this is wrong. You have two options to do that:
from socketio import ConnectionRefusedError
@socketio.on('connect')
def connect():
raise ConnectionRefusedError('authentication failed') |
I'm going to leave this issue open as a reminder that I need to properly export the |
okay, thanks very much |
emm, in fact, the ConnectionRefusedError class is not existed in the socketio/init.py, |
@chendongxtu you need to upgrade flask-socketio and all of its dependencies to the latest. As I said above, this package does not have the exception, it is in the python-socketio package, which is a dependency. |
hi @miguelgrinberg, sorry to interrupt: resolved error through updating python-socketio to latest version.
|
@miguelgrinberg When I raise the error, on the client side I get undefined when I console.log the error argument from my 'connect_error' handler. The event seems to be invoked but how do I get the message? |
@YuqiaoS can I see your code? |
@miguelgrinberg So the frontend is not printing the error seems to be an error from the https://github.com/MetinSeylan/Vue-Socket.io lib I'm using, as I do get an xhr error when not using that. (yea there was an update to fix this..gotta update the package) So I get |
You are not showing code nor logs, so I cannot say. Get logging enabled in the server and you will see what the server is sending back. |
Here's the log. The message seems to be sent.
|
The server is sending a normal message with the string "i deny u". This isn't what I expect would be sent when you raise a connection refused exception. Are you sure you are raising an exception? I just don't see how that could translate to a normal message. |
|
This maybe should be in a seperate issue but |
in the test demo, this works well, and i can see the data {"data": "Connected", "count":0} in the webbrowser.
but if i use it like following:
then in the browser, it will try to connect, but the strange place is that i can not see the data {"data": "Connected", "count":0} in the webbrowser console, i have used ipdb to trace, and it really has sent the data. so i am confused why client can not recieve the response data?
can you help me? thanks
this is the pic without return False
this is the pic with return False:
The text was updated successfully, but these errors were encountered: