diff --git a/v1/client/client.go b/v1/client/client.go index 048228c..1071736 100644 --- a/v1/client/client.go +++ b/v1/client/client.go @@ -189,7 +189,10 @@ func (wsClient *SafeWebsocketClient) connect() error { }) wsClient.mu.WriteHandler(func() error { - wsClient.conn.Close() + if wsClient.conn != nil { + wsClient.conn.Close() + } + ctx, cancel := context.WithCancel(context.Background()) wsClient.ctx = ctx wsClient.cancel = cancel