         } else if type == PacketType.NOOP {
             doPoll()
         } else if type == PacketType.PONG {
-            gotPong = true
+            pongsMissed = 0
             
             // We should upgrade
             if message == "3probe" {

    private var fastUpgrade = false
    private var forcePolling = false
    private var forceWebsockets = false
    private var gotPong = true
    private var pingTimer:NSTimer?
    private var postWait = [String]()
    private var _polling = true
    private var probing = false

        }
    }
    
    @objc private func sendPing() {
        //Server is not responding
        if pongsMissed > pongsMissedMax {
            pingTimer?.invalidate()
            client?.engineDidClose("Ping timeout")
            return
        }
        
        ++pongsMissed
        write("", withType: PacketType.PING, withData: nil)
    }
    
