From c4e964e1159cbe1c287e8e19b30006911afe72f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Sima=CC=83o?= Date: Thu, 7 Oct 2021 07:48:15 +0000 Subject: [PATCH] closing now properly the connection --- pubsub/lib.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pubsub/lib.go b/pubsub/lib.go index 8289dea..08d8a56 100644 --- a/pubsub/lib.go +++ b/pubsub/lib.go @@ -56,7 +56,7 @@ func (p *PSCli) GetConn() *websocket.Conn { p.con = con p.con.SetCloseHandler(func(code int, text string) error { log.Printf("Connection closed: %d: %s", code, text) - p.con = nil + p.Close() return nil }) break @@ -98,7 +98,9 @@ func (p *PSCli) Read(i interface{}) error { func (p *PSCli) Close() error { if !p.closed { p.closed = true - close(p.ch) + if p.ch != nil { + close(p.ch) + } return p.con.Close() } return nil