diff --git a/socket/net/client/connector.go b/socket/net/client/connector.go index 7d0fbfd..700a1ca 100644 --- a/socket/net/client/connector.go +++ b/socket/net/client/connector.go @@ -64,8 +64,9 @@ func (c *Connectors) Connect() (readChan <-chan []byte, writeChan chan<- []byte, c.crw.DisconnectedChan = c.disconnectedChan c.crw.ReconnectedChan = c.reconnectedChan - c.stopWg.Add(2) + c.stopWg.Add(1) go c.handleReconnect() + c.stopWg.Add(1) go c.crw.HandleConnection(conn) return c.readChan, c.writeChan, nil @@ -95,7 +96,9 @@ func (c *Connectors) onDisconnected() { onDisconnected := c.OnDisconnected if nil != onDisconnected { - onDisconnected(c) + go func() { + onDisconnected(c) + }() } } diff --git a/socket/web/client/connector.go b/socket/web/client/connector.go index edadcf1..800cc9a 100644 --- a/socket/web/client/connector.go +++ b/socket/web/client/connector.go @@ -101,8 +101,9 @@ func (c *Connectors) Connect() (readChan <-chan []byte, writeChan chan<- []byte, c.crw.DisconnectedChan = c.disconnectedChan c.crw.ReconnectedChan = c.reconnectedChan - c.stopWg.Add(2) + c.stopWg.Add(1) go c.handleReconnect() + c.stopWg.Add(1) go c.crw.HandleConnection(conn) return c.readChan, c.writeChan, nil @@ -132,7 +133,9 @@ func (c *Connectors) onDisconnected() { onDisconnected := c.OnDisconnected if nil != onDisconnected { - onDisconnected(c) + go func() { + onDisconnected(c) + }() } }