diff --git a/internal/msggateway/client.go b/internal/msggateway/client.go index a5e0f4cd4c..6e31751dc8 100644 --- a/internal/msggateway/client.go +++ b/internal/msggateway/client.go @@ -446,11 +446,11 @@ func (c *Client) handlerTextMessage(b []byte) error { if err != nil { return err } + c.w.Lock() + defer c.w.Unlock() if err := c.conn.SetWriteDeadline(writeWait); err != nil { return err } - c.w.Lock() - defer c.w.Unlock() return c.conn.WriteMessage(MessageText, msgData) default: return fmt.Errorf("not support message type %s", msg.Type)