How to set timeoutIntervalForRequest in Alamofire 4.0 and swift 3.0.
Bellow code working for me swift 2.2 and Alamofire 3.0.
Alamofire.Manager.sharedInstance.session.configuration.timeoutIntervalForRequest = 300
Use this
Alamofire.SessionManager.default.session.configuration.timeoutIntervalForRequest = 300
Please read Migration guide for 4.0
Migration Guide
Thanks @hardikdevios its works 馃憤
Thanks @hardikdevios! 馃嵒
I've met the same issue, but the below code did not working for me:
Alamofire.SessionManager.default.session.configuration.timeoutIntervalForRequest = 300
but I found a solution in stackoverflow by @Jeremy, I've convert it to Swift 3:
let configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForRequest = 3
configuration.timeoutIntervalForResource = 60
let manager = Alamofire.SessionManager(configuration: configuration)
Hope can help someone else.
EDIT: The version of Alamofire is 4.6.0
@hardikdevios
Hi, Hardik thanks for the reply but this code is not working in my case. I'm using Alamofire upload multipart request.
This is how I set the timeout interval
Alamofire.SessionManager.default.session.configuration.timeoutIntervalForRequest = 300
and then I print time out
let timeout = Alamofire.SessionManager.default.session.configuration.timeoutIntervalForRequest print("\n\n timeout = (timeout)")
output
timeout = 60.0
my code to upload the image
Alamofire.upload(multipartFormData: { (form) in
form.append(data, withName: "uploadfile", fileName: imageName, mimeType: "image/jpg")
}, to: url, encodingCompletion: { result in
switch result {
}
please guide me in this problem
Thanks,
Most helpful comment
I've met the same issue, but the below code did not working for me:
but I found a solution in stackoverflow by @Jeremy, I've convert it to Swift 3:
Hope can help someone else.
EDIT: The version of Alamofire is 4.6.0