lorenzodonini / ocpp-go

Open Charge Point Protocol implementation in Go
MIT License
262 stars 125 forks source link

Stop running connections on server Stop #93

Closed michaelbeaumont closed 3 years ago

michaelbeaumont commented 3 years ago

As documented, http.Shutdown doesn't attempt to close hijacked connections. The pump goroutines will ensure onDisconnected is called for each connection.

lorenzodonini commented 3 years ago

I've taken the liberty to refactor the websocket closing logic. Since I was at it, I added a graceful shutdown when stopping the server, insipired by your PR (instead of creating a new goroutine for each open websocket, I decided to signal every writePump goroutine, so they would send the close message themselves).

Feel free to have a look at #102, and tell me if I missed something and if you agree with my changes.

lorenzodonini commented 3 years ago

May I close this one, as the same changes were contained already in https://github.com/lorenzodonini/ocpp-go/pull/102?