     }
 
     func stopPolling() {
-        session.invalidateAndCancel()
+        session.finishTasksAndInvalidate()
     }
 
     private func upgradeTransport() {

        return (urlPolling, urlWebSocket)
    }

    private func createWebsocket(andConnect connect: Bool) {
        let wsUrl = urlWebSocket + (sid == "" ? "" : "&sid=\(sid)")
        
        ws = WebSocket(url: NSURL(string: wsUrl)!,

            return .Right(str)
        }
    }
    
    private func createURLs(params: [String: AnyObject]?) -> (String, String) {
        if client == nil {
            return ("", "")
