AlamoFire does not respect timeout interval

前端 未结 6 1994
离开以前
离开以前 2021-02-01 14:03
class APIClient {
    var user = User()
    let alamoFireManager : Alamofire.Manager?
    let center = NSNotificationCenter.defaultCenter()


    init(){
        let con         


        
6条回答
  •  轮回少年
    2021-02-01 14:17

    I guess this one works for you, note that you have to declare instance of Alamofire.Manager outside the function, please see below code

    //Declare it out side the function
    var alamoFireManager : Alamofire.Manager!
    
    func callUrl() {
        let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
        configuration.timeoutIntervalForResource = 10800 // seconds
        configuration.timeoutIntervalForRequest = 10800 // seconds
    
        alamoFireManager = Alamofire.Manager(configuration: configuration)
    
        alamoFireManager.request(.POST, url, parameters: dir as? [String : AnyObject], encoding: .JSON, headers: [ "Content-Type": "application/json"])
            .responseJSON { response in
        }
    }
    

    hope this helps you

提交回复
热议问题