Alamofire: Timeout is always set to Default (60 seconds)

Created on 19 Jan 2018  ·  2Comments  ·  Source: Alamofire/Alamofire

What did you do?

I would like to have a timeout for 10 sec and I have used below code for that.
ℹ Please replace this with what you did.
class Manager {
static let shared = Manager()
var manager:SessionManager{
let manager = Alamofire.SessionManager.default
manager.session.configuration.timeoutIntervalForRequest = 10
return manager
}
}

What did you expect to happen?

ℹ Please replace this with what you expected to happen.
I was expecting a timeout to be happening after 10sec.

What happened instead?

ℹ Please replace this with of what happened instead.
But timeout will be happening every 60 sec which is default timeout.

Alamofire Environment

Alamofire version: 4.6.0
Xcode version: 9.2
Swift version: 3.2
Platform(s) running Alamofire: mac
macOS version running Xcode: 10.12.6

Demo Project

ℹ Please link to or upload a project we can download that reproduces the issue.

support

Most helpful comment

timeout is always 60 sec after using all that work

All 2 comments

Modifying a URLSession's properties after it has been assigned to a URLSession isn't supported, per Apple's documentation. You need to create the configuration separate and initialize a separate SessionManager instance with it.

In the future, you should open questions like this on Stack Overflow and tag alamofire.

Cheers. 🍻


From our Contribution Guidelines

Asking Questions

We don't use GitHub as a support forum. For any usage questions that are not specific to the project itself, please ask on Stack Overflow instead. By doing so, you'll be more likely to quickly solve your problem, and you'll allow anyone else with the same question to find the answer. This also allows maintainers to focus on improving the project for others.

timeout is always 60 sec after using all that work

Was this page helpful?
0 / 5 - 0 ratings