Search code examples
iosswiftalamofire

Alamofire timeout not working when larger than 60 seconds


In my project, I use Alamofire to send a POST request, the code looks like this:

    var request = URLRequest(url: URL(string: url as! String)!)
    request.httpMethod = method.rawValue
    request.setValue("application/json", forHTTPHeaderField: "Content-Type")
    request.httpBody = try? JSONSerialization.data(withJSONObject: parameters)
    request.timeoutInterval = 120

    let alamofireRequest = Alamofire.request(request)

    alamofireRequest.responseJSON(completionHandler: { response in
             // do somthing
    }

when I set the timeoutInterval to 10, it works well. But, when I set it to 120, after about 60 second I receive a timeout error from sever.

Does iOS has any default setting for the timeout property? It can't be lager than 60?

Where I can find some documentations for it? Hope anyone can give me some suggestion.


Solution

  • Changing the timeoutInterval in Alamofire won't change the server's timoutInterval. Server responds according to its own configuration. But if you need, you can change the timeout on the server side by modifying the API.