     }
 
     func listen() {
-        webSocketTask.receive { [weak self] result in
+        webSocketTask?.receive { [weak self] result in
             guard let self = self else {
                 return
             }


    // MARK: - Private properties

    private var webSocketTask: URLSessionWebSocketTask!
    private var urlSession: URLSession!
    private let delegateQueue = OperationQueue()
    private var pingTimer: Timer?

    }

    func ping() {
        self.webSocketTask?.sendPing { error in
            if let error = error {
                self.delegate?.webSocketDidReceiveError(connection: self, error: error)
            } else {
