Browse Source

close ws connection on Stop

pull/456/head
Anton Kaliaev 8 years ago
parent
commit
afc39febed
No known key found for this signature in database GPG Key ID: 7B6881D965918214
2 changed files with 5 additions and 1 deletions
  1. +2
    -0
      client/ws_client.go
  2. +3
    -1
      server/handlers.go

+ 2
- 0
client/ws_client.go View File

@ -85,6 +85,8 @@ func (wsc *WSClient) dial() error {
func (wsc *WSClient) OnStop() {
wsc.BaseService.OnStop()
wsc.Conn.Close()
wsc.Conn = nil
// ResultsCh/ErrorsCh is closed in receiveEventsRoutine.
}


+ 3
- 1
server/handlers.go View File

@ -373,7 +373,9 @@ func (wsc *wsConnection) OnStart() error {
func (wsc *wsConnection) OnStop() {
wsc.BaseService.OnStop()
wsc.evsw.RemoveListener(wsc.remoteAddr)
if wsc.evsw != nil {
wsc.evsw.RemoveListener(wsc.remoteAddr)
}
wsc.readTimeout.Stop()
wsc.pingTicker.Stop()
// The write loop closes the websocket connection


Loading…
Cancel
Save