         guard !isClosing else {
             return
         }
-
         Logger.debug(type: .webSocketChannel, message: "[\(host)] \(#function)")
         if let onConnect = internalHandlers.onConnect {
             onConnect(self)

    }

    func connect(delegateQueue: OperationQueue?) {
        Logger.debug(type: .webSocketChannel, message: "[\(host)] connecting")
        urlSession = URLSession(configuration: .default,
                                delegate: self,
                                delegateQueue: delegateQueue)
        webSocketTask = urlSession?.webSocketTask(with: url)
        webSocketTask?.resume()
        receive()
    }

            disconnect(error: error)
        }
    }
    
    func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
        Logger.debug(type: .webSocketChannel, message: "[\(host)] \(#function) didReceive: challenge=\(challenge.protectionSpace.host):\(challenge.protectionSpace.port), \(challenge.protectionSpace.authenticationMethod)")
        
        switch challenge.protectionSpace.authenticationMethod {
        case NSURLAuthenticationMethodHTTPBasic:
            let credential = URLCredential(user: "hoge", password: "fuga", persistence: URLCredential.Persistence.forSession)
            completionHandler(.useCredential, credential)
        default:
            completionHandler(.performDefaultHandling, nil)
        }
    }
}
