         if rd.streamError != nil || wr.streamError != nil {
             return true
         }
-        if rd.hasBytesAvailable || frames.count > 0 || inputBytesLength > 0 || outputBytesLength > 0 {
+        if rd.hasBytesAvailable || frames.count > 0 || inputBytesLength > 0 {
+            return true
+        }
+        if outputBytesLength > 0 && wr.hasSpaceAvailable{
             return true
         }
         return false

        opened = true
        ws = ws.copyOpen(request, subProtocols: subProtocols)
    }
    public func open(){
        open(ws.request, subProtocols: ws.subProtocols)
    }
    public func open(url: String){
        open(NSURLRequest(URL: NSURL(string: url)!), subProtocols: [])
    }
    public func open(url: String, subProtocols : [String]){
        open(NSURLRequest(URL: NSURL(string: url)!), subProtocols: subProtocols)
    }
    public func open(url: String, subProtocol : String){
        open(NSURLRequest(URL: NSURL(string: url)!), subProtocols: [subProtocol])
    }
    public func close(code : Int = 1000, reason : String = "Normal Closure"){
        if !opened{
            return

        opened = false
        ws.close(code, reason: reason)
    }
    /**
    Transmits message to the server over the WebSocket connection.
    
    :param: message The data to be sent to the server.
    */
    public func send(message : Any){
        if !opened{
            return
        }
        ws.send(message)
    }
    /**
    Transmits a ping to the server over the WebSocket connection.
     
    :param: optional message The data to be sent to the server.
    */
    public func ping(message : Any){
        if !opened{
            return
        }
        ws.ping(message)
    }
    /**
    Transmits a ping to the server over the WebSocket connection.
    */
    public func ping(){
        if !opened{
            return
