diff --git a/conn.go b/conn.go index 7304ba6..c4b1a82 100644 --- a/conn.go +++ b/conn.go @@ -279,6 +279,8 @@ func (c *Client) internalConnect(mock net.Conn) error { var ctx context.Context ctx, c.stop = context.WithCancel(context.Background()) + c.mu.Unlock() + // Start read loop to process messages from the server. errs := make(chan error, 3) done := make(chan struct{}, 4) @@ -297,8 +299,6 @@ func (c *Client) internalConnect(mock net.Conn) error { go c.pingLoop(errs, done, &wg, 1*time.Second) } - c.mu.Unlock() - // Send a virtual event allowing hooks for successful socket connection. c.RunHandlers(&Event{Command: INITIALIZED, Trailing: c.Server()})