I am using Alamofire 4.0.1 and I want to set a timeout for my request. I tried the solutions gived in this question:
In the first case
i have code for swift 2.3 hope it helps you, try it
let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
configuration.timeoutIntervalForResource = 10800 // seconds
configuration.timeoutIntervalForRequest = 10800 // seconds
alamoFireManager = Alamofire.Manager(configuration: configuration)
None of the above worked for me: Im on swift 4.2
Alamofire 4.5
I managed to solve it like this :
let request = Alamofire.request("routee", method: .post, parameters: data, encoding: JSONEncoding.default, headers: getHeaders())
/// getting request created by Alamofire and then updating its timeout Value
let url = URL(string: "myroute")!
var request = try URLRequest(url: url, method: method, headers: headers)
request.timeoutInterval = 900 // timeout
request = try JSONEncoding.default.encode(request, with: data)
Alamofire.request(request)
.responseJSON { response in
}