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

trio_websocket/_impl.py: Don't reply to pings on a locally closed connection #198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

geronimogoemon
Copy link

@geronimogoemon geronimogoemon commented Mar 28, 2025

I encountered this issue in my application and applied the following fix in my local fork. I am making the PR in case there is interest in applying this fix on the main repo.

For clarity, the source of the problem seems to be the fact that when calling aclose() we will send a CloseConnection message here and then allow context switch on await before we disable processing of incoming messages here but after wsproto will change its connection state to LOCAL_CLOSING. During that time gap we can receive Ping message which will result in exception upon handling it.

Fixes #184

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you-- would you mind trying to add unit test coverage for this?

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

Successfully merging this pull request may close these issues.

_handle_ping_event() occasionally sends to closed socket
2 participants