You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HTTP2: Hang when sending multiple requests from a HttpClient #30295
My guess is that this is a duplicate of one or more of those issues, by themselves or in combination. I believe @geoffkizer will be putting up a PR soon with fixes; hopefully you can verify it addresses this issue, and if not, it'll be important to figure out why.
Yep, it's very likely related to those issues. The trace you posted is pretty weird, but we have some weird coordination issues here. I'm hopeful this will get addressed as part of the overall fix here.
I'm able to reproduce the issue with the latest nightly. However, I'm observing a different behaviour when manually copying the latest corefx build artifacts to the framework's shared folder:
The client is consistently timing out at the first iteration because it's failing to establish new streams. It might be because I copied corefx files inappropriately, however I'm not observing any runtime errors on the client side. @geoffkizer any hints?
I was able to repro with the original code from above.
@JamesNK, am I correcting in thinking that you are not sending any request body at all here? Because it looks like we're writing the HEADERS for the second request into our buffer, but we're never flushing them because you never send any body data. So the server never receives anything and the test times out.
If you really want to just send the headers and no data, then to ensure they get sent, you need to call FlushAsync on the request body.
How come the first request succeeds? The hang only happens after two or three requests.
The first request is getting lucky, basically. We may need to flush the buffer internally for a variety of reasons. In this case, it looks like it's because we're sending a SETTINGS ACK frame for the initial SETTINGS from the server.
When a HTTP/2 client streaming request starts should the gRPC client always start with a FlushAsync on the stream from HttpContext?
You only need to call FlushAsync when you want to ensure that any pending bits, including the headers themselves, are actually written out to the wire.
I assume the common case is that you issue a POST, get the request body stream, write some bits into it, and then flush it. In which case you should be fine. In fact, that's why we do this sort of buffering logic, to try to do a single write to the wire that includes HEADERS and DATA for the request body.
If you aren't going to immediately send request body data, but you do want the request to be sent to the server immediately, then you need to call FlushAsync on the request body to guarantee this.
@geoffkizer it seems that PR dotnet/corefx#39638 (in release/3.0 branch PR dotnet/corefx#39775) didn't really fix this issue.
I will update their text to mention it as "incomplete fix for".
Please let me know if it is wrong. Thanks!
Perhaps we should have an issue specifically for the second HttpClient issue (re RST_STREAM with NO_ERROR). That makes for a better historical record here of what was actually fixed.
Activity
JamesNK commentedon Jul 18, 2019
The network traffic in Wireshark is weird
In this example the third call hung.
3 is where the hang occurs.
stephentoub commentedon Jul 18, 2019
There are currently several RST_STREAM/dispose/cancel related issues that @geoffkizer is revamping the implementation to fix:
https://github.com/dotnet/corefx/issues/39461
https://github.com/dotnet/corefx/issues/39460
https://github.com/dotnet/corefx/issues/39459
https://github.com/dotnet/corefx/issues/39458
https://github.com/dotnet/corefx/issues/39404
My guess is that this is a duplicate of one or more of those issues, by themselves or in combination. I believe @geoffkizer will be putting up a PR soon with fixes; hopefully you can verify it addresses this issue, and if not, it'll be important to figure out why.
geoffkizer commentedon Jul 18, 2019
Yep, it's very likely related to those issues. The trace you posted is pretty weird, but we have some weird coordination issues here. I'm hopeful this will get addressed as part of the overall fix here.
JamesNK commentedon Jul 27, 2019
This is still broken.
geoffkizer commentedon Jul 27, 2019
Likely the same issue as dotnet/corefx#39819
eiriktsarpalis commentedon Jul 29, 2019
I'm able to reproduce the issue with the latest nightly. However, I'm observing a different behaviour when manually copying the latest corefx build artifacts to the framework's shared folder:
The client is consistently timing out at the first iteration because it's failing to establish new streams. It might be because I copied corefx files inappropriately, however I'm not observing any runtime errors on the client side. @geoffkizer any hints?
geoffkizer commentedon Jul 29, 2019
I don't think this is the same issue. In the trace you provided, we're getting a GOAWAY from the server.
We need to investigate anyway, though. How do you repro this?
geoffkizer commentedon Jul 30, 2019
I was able to repro with the original code from above.
@JamesNK, am I correcting in thinking that you are not sending any request body at all here? Because it looks like we're writing the HEADERS for the second request into our buffer, but we're never flushing them because you never send any body data. So the server never receives anything and the test times out.
If you really want to just send the headers and no data, then to ensure they get sent, you need to call FlushAsync on the request body.
JamesNK commentedon Jul 30, 2019
Yes. I came across this issue by accident: someone uses the gRPC client to call an address that is not implemented, and so immediately returns.
How come the first request succeeds? The hang only happens after two or three requests.
When a HTTP/2 client streaming request starts should the gRPC client always start with a FlushAsync on the stream from HttpContext?
geoffkizer commentedon Jul 30, 2019
The first request is getting lucky, basically. We may need to flush the buffer internally for a variety of reasons. In this case, it looks like it's because we're sending a SETTINGS ACK frame for the initial SETTINGS from the server.
You only need to call FlushAsync when you want to ensure that any pending bits, including the headers themselves, are actually written out to the wire.
I assume the common case is that you issue a POST, get the request body stream, write some bits into it, and then flush it. In which case you should be fine. In fact, that's why we do this sort of buffering logic, to try to do a single write to the wire that includes HEADERS and DATA for the request body.
If you aren't going to immediately send request body data, but you do want the request to be sent to the server immediately, then you need to call FlushAsync on the request body to guarantee this.
10 remaining items
davidsh commentedon Aug 2, 2019
The release/3.0 branch is locked until at least Monday/Tuesday next week. So, if you need @stephentoub to review changes on that PR then that's fine.
karelz commentedon Aug 3, 2019
Parts of the fixes were in master (5.0) in PR dotnet/corefx#39638 and also in release/3.0 branch (3.0) in PR dotnet/corefx#39775.
karelz commentedon Aug 3, 2019
@geoffkizer it seems that PR dotnet/corefx#39638 (in release/3.0 branch PR dotnet/corefx#39775) didn't really fix this issue.
I will update their text to mention it as "incomplete fix for".
Please let me know if it is wrong. Thanks!
karelz commentedon Aug 3, 2019
The bug was fixed in master (5.0) in PR dotnet/corefx#39834.
Port to release/3.0 is pending in PR dotnet/corefx#39874.
geoffkizer commentedon Aug 3, 2019
@karelz There were multiple issues here -- two in HttpClient, one in GRPC.
dotnet/corefx#39638 fixed the first issue and enabled discovering the other issues.
dotnet/corefx#39882 is the PR to fix the second HttpClient issue.
geoffkizer commentedon Aug 3, 2019
Perhaps we should have an issue specifically for the second HttpClient issue (re RST_STREAM with NO_ERROR). That makes for a better historical record here of what was actually fixed.
karelz commentedon Aug 3, 2019
Yes, we should have filed separate issues. Let's call it incomplete fix at this moment as this issue tracks technically multiple bugs ...
geoffkizer commentedon Aug 5, 2019
reopen for 3.0
karelz commentedon Aug 8, 2019
Fixed for 3.0 in PR dotnet/corefx#40112 and in master (5.0) in PR dotnet/corefx#39882.