超过60秒时,Alamofire超时不起作用

时间:2017-03-07 01:22:34

标签: ios swift alamofire

在我的项目中,我使用Alamofire发送POST请求,代码如下:

    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
    }

当我将timeoutInterval设置为10时,效果很好。但是,当我将其设置为120时,大约60秒后我从服务器收到超时错误。

iOS是否有超时属性的默认设置?它不能超过60?

我可以在哪里找到一些文件? 希望有人能给我一些建议。

1 个答案:

答案 0 :(得分:3)

更改Alamofire中的timeoutInterval无法更改服务器timoutInterval。 服务器根据自己的配置进行响应。 但是如果需要,可以通过修改API来更改服务器端的超时。