-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTPClient.remoteConnectionClosed
errors
#488
Comments
Hi @MahdiBM, thanks for posting this issue. A couple of follow up questions:
Notes:
|
Okay, digging into this a little deeper. AWS Application Load Balancer seems to send a GOAWAY after 10k streams:
I wonder if there is a way to detect this behavior before sending out further streams. Also if we receive a GOAWAY we will fail the request either with a:
error. Maybe we should do a better job in differentiating those. |
Okay, this is seemingly defined behavior:
|
so it supports http/2.
|
20-50% or 20 to 50 requests in total? How long does such a request normally take? When I curl this
I can see that the TLS cert is Amazon issued, which is a hint that we run against an AWS owned Load Balancer/API Gateway. The 10k stream limit described above might be the issue here. |
Okay, running tests against the API (https://api.clashroyale.com) you provided, AHC fails over after exactly 10k requests. |
@MahdiBM Do you sometimes see an error like this: |
20% to 50%. It takes a normal amount of time ... less than 5s, usually 2s or less.
Nice that didn't take long to reproduce :)
Correct. Rarely. But yes. |
Interestingly the Go client seems to have the same issue: |
More context in the AWS dev forums: |
Interesting quotes from the RFC:
This is NOT what the AWS ALB does.
We could auto retry requests. |
I'm personally doing fine pinning my AHC to |
.http1Only is the best workaround for now. |
I'm also getting these issues when trying to download assets from GitHub releases. Pinning to 1.6.4 helps, but the issue is reproducible with both 1.7.0 and 1.8.0 |
For those who are having this issue and use Vapor:I initially thought it's a bit harder to change client's HTTPVersion in Vapor, but a few hours ago i took another look and found out its actually quite simple. app.http.client.configuration.httpVersion = .http1Only For others who directly use HTTPClient without Vapor:Read this pull request's first comment to see how to change your |
In general, after #490 we should see much better error messages. You should normally see a GOAWAY error message. |
@MaxDesiatov Do you see after how many requests you see this error? |
I'm not sure what you are referring to by "how many requests". I issue just a single request in my app, and it never finishes a download properly, always throwing |
`async-http-client` package is now pinned to 1.6.4, as 1.7.0 and later versions caused issues with toolchain downloads (see swift-server/async-http-client#488 for more details). I've also updated toolchain downloader code to bubble up download errors, which previously were hidden and made it very hard to diagnose these issues. * Use SwiftWasm 5.5.0, bump version to 0.12.0 * Pin AHC to 1.8.0 * Pin AHC to 1.6.4, always remove downloaded archives * Fix `defer` build issue
Here's a URL that I'm requesting, if that helps https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.5.0-RELEASE/swift-wasm-5.5.0-RELEASE-macos_arm64.pkg I'm using |
@MaxDesiatov Do you see the error on the first request? |
I'm making a single request, and I guess that's implied to be the first request? A single run of my code issues only a single request, which always fails with |
Given that OP sees the issue appearing only after some amount of requests, I'm not sure now if my issue is exactly the same, but the error I'm seeing thrown is the same. And my issue is stably reproducible. Please let me know if I should create a separate ticket here for it. |
@MaxDesiatov Yes, the real issue in your case is very likely another one (and not http2 GOAWAY frames). I think we fixed your issue today with #490. Would you mind trying it once with current AHC main? |
With |
Yep, it works great on 1.6.4v only. Having the same issues on production and downgraded to 1.6.4 for now. Also experiencing the same issues described by @MaxDesiatov, after 3 or 4 requests it hangs and the client returns |
@MaxDesiatov I could reproduce your issue. Thanks for the report. A fix has been proposed to nio-http2: apple/swift-nio-http2#317 |
Perfect, thanks! |
### Motivation In the AsyncHTTPClient the read event is not always forwarded right away. We have seen instances, in which we see a `HTTPClientError.remoteConnectionClosed` error, on requests that finish normally. swift-server/async-http-client#488 On deeper inspection, I noticed: If there is no unsatisfied read event, when a stream is closed, the pending reads are not forwarded. This can lead to response bytes being ignored on successful requests. NIOHTTP2 should behave as NIO and force forward all pending reads on channelInactive. ### Changes - Forward all pending reads on channelInactive even if no read event has hit the channel ### Result All requests will receive the complete request body.
@MaxDesiatov we just shipped |
thanks, this indeed fixes the issue for me |
@MahdiBM I have created two tickets #505 and #506 that describe the AWS ALB issue at more depth. Since we have also solved @MaxDesiatov's issue, do you mind if I close this ticket and we track work on the new issues? |
@robipresotto Would you mind checking if your problem got fixed with |
@fabianfett Sure, no problem, you can close this issue. |
It works great 👍🏻 thanks a lot guys :))) |
Current Behavior
After a few hours, e.g. 2.5 hours, my app starts to throw
HTTPClient.remoteConnectionClosed
errors.Expected Behavior
No
HTTPClient
errors should be thrown.What am i doing?
In Vapor, I have a piece of code like so:
This method is called 2.5/s, and basically crawls another API.
Though, when the errors start happening, the throwing happens even outside this code, and with every eligible API call.
More Info
1.7.0
and latest commit and1.6.4
.Everything works fine on
1.6.4
, but using the other two results in the error..automatic
to.http1Only
. Can try this if you need more info.I can attempt to make a repro project if it seems necessary.
The text was updated successfully, but these errors were encountered: