-
-
Notifications
You must be signed in to change notification settings - Fork 892
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
return False in connect handler won't disconnect connection #1029
Comments
I believe it is the client who is supposed to close the physical connection when a disconnect is received (and in fact there is an open issue about that as well). |
Thanks for your explaination, After looking into the implement details, I found a This behavior is missing in documentation and should be more consistent IMO. And I think "Believe clients should do something" by default is not a good idea, maybe a force connection closing in the issue you mentioned is a better consideration.
|
@StoneMoe Kind of a late response but I want to clarify that there seems to be two main reasons why the connection isn't fully closed on return False by default.
|
@lazercorn Thanks for the reply, discussion and opinions are never late :)
Yes you're right.
I would prefer to put a doubt on this, since Flask-SocketIO isn't only for large scale system, and clients aren't always able to be trusted. When you say "best practice" it should be limited in some senario. |
@StoneMoe Yes you're correct that Flask-SocketIO does not seem to close invalid connections after some time. You would have to create a custom solution. My solution is to return True, not False. Then send a custom disconnect event to client telling them to initiate the close. Reason I returned True is if you returned False and tried to disconnect client from server after, you'd find client doesn't disconnect. |
@lazercorn Your custom solution will also leave dangling connections when client doesn't close connection as you expect. this may lead to DoS vulnerability by exhausting file descriptor resource, that's why I opened this issue. But I will leave this issue closed. |
@StoneMoe That's why you must initiate close from server if client doesn't initiate close after some time, otherwise as you mentioned, asking the client to initiate close is pointless if the client isn't trusted. I figured because I had already mentioned it, that was implied. By doing this, you prevent resource exhaustion by malicious clients abusing TIME_WAIT and also avoid unnecessary resource exhaustion by nonmalicious clients. |
@lazercorn Exactly, that's why we need to take scenario into account :D |
Version: 4.1 (current latest)
I found this when working on this issue(miguelgrinberg/python-engineio#128 (comment))
In Socket.IO server options documentation, it says:
The server accept the connection actually, but won't send any data to the client.
Is this an expected behavior?
The text was updated successfully, but these errors were encountered: