Hi I'm trying to create a custom SessionManager in Alamofire in order to change the default timeoutIntervalForRequest value. I'm using the code below:
let configuration=URLSessionConfiguration.default
configuration.timeoutIntervalForRequest=20
let sessionManager=Alamofire.SessionManager(configuration:configuration)
sessionManager.request("my url", method: .post, parameters: params, encoding: JSONEncoding.default, headers: header)
.responseJSON(completionHandler: { (response) in
if response.result.isSuccess{
//here goes the rest of my code
}
}
else{
//here goes the connection error part
}
})
The problem is I'm always getting the error part and when I print the response in error part, it looks like this:
finished with error - code: -999
FAILURE: Error Domain=NSURLErrorDomain Code=-999 "cancelled"
as if my request immediately cancels. If I change the sessionManager to Alamofire that is the default manager, it works fine but I need to change timeoutIntervalForRequest value. I'm using Xcode 9.3 and swift 4 and Alamofire 4.7.2 . Any Suggestions?