Alamofire 4.0: timeoutIntervalForRequest

Created on 30 Sep 2016  路  5Comments  路  Source: Alamofire/Alamofire

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

support

Most helpful comment

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

All 5 comments

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,

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simonliotier picture simonliotier  路  3Comments

hengchengfei picture hengchengfei  路  3Comments

matthijsotterloo picture matthijsotterloo  路  3Comments

lvandal picture lvandal  路  3Comments

sarbogast picture sarbogast  路  3Comments