miguelgrinberg / simple-websocket

Simple WebSocket server and client for Python.
MIT License
78 stars 17 forks source link

Server now closes socket when connection is dropped by client ( Fix #19 ) #20

Closed innuos-ccarvalho closed 1 year ago

innuos-ccarvalho commented 2 years ago

Server now closes socket when connection is dropped by client to avoid sockets hanging in CLOSE_WAIT state.

This aims at solving issue #19 as discussed. I changed the solution a bit from what was proposed at first to follow the pattern already existent in Client. I'm not sure however about the best reason and message for the disconnection.

I'm not sure about the testing rules for this branch, I tested this case has best I could manually. If I should do something else, like updating automatic tests, please do say.

Also took the liberty to fix a couple of typos in comments, hope you don't mind.

Thank you

codecov-commenter commented 2 years ago

Codecov Report

Merging #20 (633dbab) into main (271f8fc) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main       #20   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          195       200    +5     
  Branches        41        42    +1     
=========================================
+ Hits           195       200    +5     
Impacted Files Coverage Δ
src/simple_websocket/ws.py 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

miguelgrinberg commented 1 year ago

This is now merged. I have simplified the closing logic a bit, and also added a missing close for the selector, which is used when the optional pings are enabled. Thanks!

innuos-ccarvalho commented 1 year ago

Thanks for your work!