r3labs / sse

Server Sent Events server and client for Golang
Mozilla Public License 2.0
871 stars 180 forks source link

server.Close() does not close clients connections #93

Closed GreyXor closed 3 years ago

GreyXor commented 3 years ago

Hello @purehyperbole , I found out that Server.Close() does not close clients connections, which prevents me from doing a graceful shutdown of my net/http server

https://play.golang.org/p/qHxVR5W6xnA

To test: 1/ Execute program (there is 0 connections) 2/ Connect some client (with curl for example) (curl "http://127.0.0.1:1337/stream?stream=messages") 3/ CTRL+C the server should call Server.Close() but the connections are still open

purehyperbole commented 3 years ago

Hey @GreyXor

Thanks for raising the issue. It was caused by a cleanup function that was blocking the handler from exiting.

This should now be resolved on v2.3.5, please let me know if this fixes your issue.

GreyXor commented 3 years ago

Hi @purehyperbole, I confirm that is fixed and clients are now correctly closed. Thanks for the fast fix!