This is an error in the Apple NSURLSessionTaskMetrics code and occurs during a network request, when the user clock moves backward enough so that the timestamp for the start of the request is after the request timestamp. This can be reproduced using a network debugging proxy and manual clock settings and only happens with iOS 10.0 to, but not including iOS 10.2
If you use Alamofire and you do not need NSURLSessionTaskMetrics , you can work around this by using the custom SessionDelegate for your SessionManager and overriding the responds(to aSelector..) function, for example:
class MySessionDelegate: Alamofire.SessionDelegate { override public func responds(to aSelector: Selector) -> Bool { let result: Bool = super.responds(to: aSelector) if
If you use the default SessionManager (for example, call Alamofire.request(...) ), you can create your own SessionManager to use your custom SessionDelegate :
let sessionManager: Alamofire.SessionManager = { let configuration: URLSessionConfiguration = URLSessionConfiguration.default configuration.httpAdditionalHeaders = SessionManager.defaultHTTPHeaders return Alamofire.SessionManager(configuration: configuration, delegate: MySessionDelegate(), serverTrustPolicyManager: nil) }()
And now, instead of calling Alamofire.request(...) you call sessionManager.request(...)
source share