Hi.
I'm experiencing an issue with Alamofire 4.4 when getting paginated results... What i'm doing is getting a list of objects with this call (which works fine for the first page)
Alamo.request(items/list,
method:get,
parameters:param,
encoding: JSONEncoding.default,
headers: headers).responseJSON(queue: queue,
completionHandler: { response in ... }
The result of the call above would be paginated with a next url (with a cursor) to call and the first page results... So i'm calling it straight away as the url
Alamo.request(items/list?cursor=cgD0xMADdd,
method:get,
parameters:param,
encoding: JSONEncoding.default,
headers: headers).responseJSON(queue: queue,
completionHandler: { response in
print(response.metrics?.taskInterval)
}
This second call sometimes acts very fast but sometimes can take up to a minute. Note that no other call to other APIs in the project is acting this way... I also tried to remove the query params and adding them as parameters in the Alamo.request but did not work.
Here the full metrics. Note that all delay is between (Request Start) and (Request End). Can you help me?
(Start Date) 2017-03-03 00:23:15 +0000
(Duration) 59.880781 seconds
(End Date) 2017-03-03 00:24:15 +0000
(Fetch Start) 2017-03-03 00:23:15 +0000
(Domain Lookup Start) 2017-03-03 00:24:15 +0000
(Domain Lookup End) 2017-03-03 00:24:15 +0000
(Connect Start) 2017-03-03 00:24:15 +0000
(Secure Connection Start) 2017-03-03 00:24:15 +0000
(Secure Connection End) 2017-03-03 00:24:15 +0000
(Connect End) 2017-03-03 00:24:15 +0000
(Request Start) 2017-03-03 00:23:15 +0000
(Request End) 2017-03-03 00:24:15 +0000
(Response Start) 2017-03-03 00:24:15 +0000
(Response End) 2017-03-03 00:24:15 +0000
There doesn't seem to be anything Alamofire related here. I will say that having JSON body data in .get requests can cause issues in some servers, so make sure you're properly creating the requests you need.
Otherwise, we use our GitHub project for bug reports and feature requests. In the future, you should open questions like this on Stack Overflow and tag alamofire.
Cheers. 🍻
From our Contribution Guidelines
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.
Hi @jshier ,
Sure. Thanks for your response and sorry for the noise... I actually found the problem and maybe this can be improved on Alamofire as well...
So the problem was related to the fact I was creating a request with an empty dictionary within parameters...
self.sessionManager.request(url,
method:method,
**parameters: [:]**,
encoding: JSONEncoding.default,
headers: headers).responseJSON { response in ... }
This was adding an extra Content-Length=2 header in the request which kept the load balancer waiting for these bytes (which where never coming). By removing parameters: [:] everything works smoothly...
I just though you might want to investigate that. It's not actually a bug since I was misusing the library, so my bad, but it might be of your interest. Next time i'll use stackoverflow.
Thanks again.
I had the same problem, caused by encoding with empty parameters, thanks @teripaquitinho
This Info also saved our sanity! Thank you for sharing 👍
@teripaquitinho Thanks so much for this, just spent a day trying to figure out why our app would not work with our new API environment.
@teripaquitinho Thanks a lot, I struggled against this for days...
@teripaquitinho Thanks a lot, It helps, you rock
Most helpful comment
Hi @jshier ,
Sure. Thanks for your response and sorry for the noise... I actually found the problem and maybe this can be improved on Alamofire as well...
So the problem was related to the fact I was creating a request with an empty dictionary within
parameters...This was adding an extra
Content-Length=2header in the request which kept the load balancer waiting for these bytes (which where never coming). By removingparameters: [:]everything works smoothly...I just though you might want to investigate that. It's not actually a bug since I was misusing the library, so my bad, but it might be of your interest. Next time i'll use stackoverflow.
Thanks again.