     
     private func reconnectWebSocket() {
         
+        // if the server URL hasn't been set, there's no point continuing
+        guard serverURL != nil else {
+            return
+        }
+        
         // close and tidy if we already had a socket
         if let s = socket {
             s.close()

        }
    }
    
    func webSocket(webSocket: SRWebSocket!, didReceiveMessage message: AnyObject!) {
        if let s = message as? String {
            if let data = s.dataUsingEncoding(NSUTF8StringEncoding) {

                    if let data = JSON as? [String : AnyObject] {
                        let u = User.sharedInstance
                        u.setValuesForKeysWithDictionary(data)
                        
                        self.reconnectWebSocket()
                        
                        onSuccess(u)
                    } else {
                        if let fail = onFailure {
