Fix a panic on close bug (#28)
Co-authored-by: James Mills <prologic@shortcircuit.net.au> Reviewed-on: https://git.mills.io/prologic/msgbus/pulls/28
This commit is contained in:
parent
7b71102aa8
commit
5c065e91ed
|
@ -199,9 +199,11 @@ func NewSubscriber(client *Client, topic string, index int, handler msgbus.Handl
|
|||
|
||||
func (s *Subscriber) closeAndReconnect() {
|
||||
s.RLock()
|
||||
s.conn.Close(websocket.StatusNormalClosure, "Closing and reconnecting...")
|
||||
if s.conn != nil {
|
||||
s.conn.Close(websocket.StatusNormalClosure, "Closing and reconnecting...")
|
||||
go s.connect()
|
||||
}
|
||||
s.RUnlock()
|
||||
go s.connect()
|
||||
}
|
||||
|
||||
func (s *Subscriber) connect() {
|
||||
|
|
Loading…
Reference in New Issue