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

Session close timeout fails due to mixing relative and absolute times #50

Closed
gmyers18 opened this issue May 7, 2018 · 1 comment
Closed
Assignees
Labels

Comments

@gmyers18
Copy link

gmyers18 commented May 7, 2018

The sent_close_time in WebSocket.State is an absolute epoch time (see line 240). But Session._check_close_timeout() performs a comparison which is based on elapsed seconds relative to the start of the session (see line 262), thus the close timeout will never fire. A simple fix would be to store "elapsed session time" in sent_close_time.

On a related note, it is a bit counter-intuitive to me that every call to WebSocket.close() updates the sent_close_time. Thus, for a case where multiple close packets happen to be sent, the close timeout check is always relative to the last packet rather than the first. If one is relying on the close timeout check to close out a session where the server fails to respond, and there is a programming error where close() is being called periodically in a loop, then the timeout will likely never succeed.

@willmcgugan willmcgugan added the bug label May 8, 2018
@willmcgugan willmcgugan self-assigned this May 8, 2018
willmcgugan added a commit that referenced this issue May 8, 2018
@willmcgugan willmcgugan mentioned this issue May 9, 2018
1 task
willmcgugan added a commit that referenced this issue May 9, 2018
@willmcgugan
Copy link
Contributor

Fixed in 0.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants