trio-websocket
trio-websocket copied to clipboard
trio_websocket/_impl.py: Don't reply to pings on a locally closed connection
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