                 }
             }
             defer {
-                readyState = .Closing
+                privateReadyState = .Closing
             }
             for ;; {
                 ws.readDeadline = NSDate().dateByAddingTimeInterval(60)

                    }
                }
                ws.close(closeCode, reason: closeReason)
                readyState = WebSocketReadyState.Closed
                fireEvent(.Closed, code: closeCode, reason: closeReason, wasClean: closeClean)
            }
        }
        do {
            let ws = try WebSocketConn(self.request, services: TCPConnService(self.services.rawValue), protocols: self.subProtocols, compression: self.compression)
            wso = ws
            self.subProtocol = ws.subProtocol
            fireEvent(.Opened)
            var pongFrames : [Frame] = []
            dispatch_async(dispatch_queue_create(nil, nil)) {

        return request.URL!.description
    }
    /// A string indicating the name of the sub-protocol the server selected; this will be one of the strings specified in the protocols parameter when creating the WebSocket object.
    public var subProtocol : String {
        get { return privateSubProtocol }
    }
    private var privateSubProtocol : String {
        get { lock(); defer { unlock() }; return _subProtocol }
        set { lock(); defer { unlock() }; _subProtocol = newValue }
    }
