     private var didDisconnect = false
     private var readyToWrite = false
     private var headerSecKey = ""
-    private let mutex = NSLock()
+    private let readyToWriteMutex = NSLock()
     private let notificationCenter = NotificationCenter.default
     private var canDispatch: Bool {
-        mutex.lock()
+        readyToWriteMutex.lock()
         let canWork = readyToWrite
-        mutex.unlock()
+        readyToWriteMutex.unlock()
         return canWork
     }
     /// The shared processing queue used for all WebSocket.

        guard !didDisconnect else { return }
        didDisconnect = true
        isConnecting = false
        connected = false
        guard canDispatch else {return}
        callbackQueue.async { [weak self] in
            guard let s = self else { return }

    private var outputStream: OutputStream?
    private var connected = false
    private var isConnecting = false
    private let connectedMutex = NSLock()
    private var compressionState = CompressionState()
    private var writeQueue = OperationQueue()
    private var readStack = [WSResponse]()
