{"push_id":2875312118,"size":1,"distinct_size":1,"ref":"refs/heads/master","head":"61d7b58c5d488b3c4b2e52bc0cbaab87bcdc7767","before":"9fc5271a8d0c0063e8fff03ccc3f4b1ebe2b1a88","commits":[{"sha":"61d7b58c5d488b3c4b2e52bc0cbaab87bcdc7767","author":{"name":"Sam Mueller","email":"fc0fa987d0ba84438b93062d41a4ce0da6ff69ff@gmail.com"},"message":"Expose PhxTimer and reconnect/heartbeat events & give channel its own reconnect fn\n\nWe found a few stability problems with our connection, mainly to do with deadzones and reconnection after being backgrounded. The issues stemmed from the timers, so making them accessbile allowed finer grained control and we saw significant stability improvements:\n\n``` swift\nprivate func onError(error: Error) {\n        let nsError = error as NSError\n        if nsError.domain == NSPOSIXErrorDomain, socket.autoReconnect {\n            switch Int32(nsError.code) {\n            case\n                ECONNREFUSED, // server is down (offline, crashed, etc.)\n                ENOTCONN: // socket can't connect (airplane mode, no service, etc.)\n                socket.reconnectTimer.scheduleTimeout()\n            default: break\n            }\n        }\n        print(\"[NETWORK PERF] websocket error connecting: \\(nsError.localizedDescription)\")\n        sendError(withName: EventName.onError, error: error)\n    }\n```\n\nHere we are clearing the pendingHeartbeatRef when coming back from app being in background, because it will delay fire (paused timers?) and wreck the connection:\n\n``` swift\nfunc reconnect() {\n        guard !socket.isConnected else { return }\n        socket.pendingHeartbeatRef = nil\n        socket.connect()\n    }\n```","distinct":true,"url":"https://api.github.com/repos/sjmueller/SwiftPhoenixClient/commits/61d7b58c5d488b3c4b2e52bc0cbaab87bcdc7767"}]}
{"actor":{"display_login":"sjmueller"}}