Aluminum Aluminum - 7 months ago 96
Swift Question

Alamofire ignores timeoutIntervalForRequest and timeoutIntervalForResource parameters

I am currently trying to decrease the default values for

for every Alamofire remote calls in my iOS app since I don't want it to wait 60 seconds and 7 days respectively.

This is my code:

Alamofire.Manager.sharedInstance.session.configuration.timeoutIntervalForRequest = 30
Alamofire.Manager.sharedInstance.session.configuration.timeoutIntervalForResource = 30

let parameters = [
"foo": [1,2,3],
"bar": [
"baz": "qux"

Alamofire.Manager.sharedInstance.request(.POST, "someURL", parameters: parameters, encoding: .JSON) {
(response) in


This is my log:

Timeline: { "Latency": 60.977 secs, "Request Duration": 60.977 secs, "Serialization Duration": 0.000 secs, "Total Duration": 60.977 secs }

As you can see the
Request Duration
value is over 30 seconds.

Does this depends on the fact that I use
instead of


I have opened an issue on the official Alamofire GitHub page and this was their opinion about that:

Changing the values of the configuration in a session that's already active has no effect. According to Apple's documentation on NSURLSession: Changing mutable values within the configuration object has no effect on the current session, but you can create a new session with the modified configuration object.

I suggest you create your manager instance and customize its configuration, as per our documentation.