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

            return .Right(str)
        }
    }

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

                }
                
                if !forcePolling && !forceWebsockets && upgradeWs {
                    createWebsocketAndConnect(true)
                }
            }
        } catch {
