Moya: Moya request timing out - works fine in Alamofire directly
I have an endpoint that’s timing out when using Moya.
getApiProvider().request(.getOrder(id: 4))
.subscribe { i in
print(i)
}
No errors, just the following in the console:
2016-12-17 12:19:20.223132 TestApp[46055:1474324] [] nw_endpoint_flow_service_writes [3.1 176.34.225.3:80 ready socket-flow (satisfied)] Write request has 4294967295 frame count, 0 byte count
I don’t see any logs showing this particular request on the server, and other requests from Moya are working fine.
- Moya configuration code (tidied up to include only the endpoint in question for brevity)
- getApiProvider() code
When I perform an identical request with Alamofire…
Alamofire.request(
"http://localhost:3000/api/v1/assistants/order?order_id=4",
method: HTTPMethod.get,
parameters: nil,
encoding: JSONEncoding.default,
headers: [ "Authorization" : "Bearer <token>" ]
)
.response(completionHandler: { response in
print(JSON(data: response.data!))
})
…the request completes without issue.
I’m sure it’s likely something simple I’m overlooking - any ideas what may be causing this?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 31 (17 by maintainers)
@scottrhoyt Just tried your suggestion this morning - that fixed it!
Looks like there’s an issue with Alamofire timing out when sending
GET
requests using Alamofire with JSON in the body: https://github.com/Alamofire/Alamofire/issues/1530, https://github.com/Alamofire/Alamofire/issues/1819If you guys think this use case is common enough then this conditional is fine; perhaps I could add a pointer in the documentation though.
Otherwise I’d be happy to discuss other ways of handling this automatically when using JSONEncoding 👍 (Although perhaps that’s an issue for Alamofire itself)
Thank you so much everyone for your help!
@jonlambert Updating your view model code to:
Results in expected behavior:
@jonlambert Any chance you could create a public repo that reproduces the problem? I’d jump in and do some debugging.