Grpc.Net.Client weird second request call time out exception

Working on a server-client communication using protobufs. From clients side I use GrpcChannel from the Grpc.Net.Clien package. Encountering a strange problem, where the second service call to server is throwing an
HttpRequestException: The connection timed out from inactivity
HttpRequestException: The connection timed out from inactivity
Interestingly enough, everything on the server's side is working, yet on this second request, the client's side gets an error. The code bellow that reproduces this bug.
30 Replies
Cosmic Centipede
Cosmic CentipedeOP9mo ago
And here is the error of the second service call: { "opinion": "USERNAME_OPINION_OK" } Failed on the 2 request: Status(StatusCode="Unavailable", Detail="Error starting gRPC call. HttpRequestException: The connection timed out from inactivity. (http://serverUrl) QuicException: The connection timed out from inactivity.", DebugException="System.Net.Http.HttpRequestException: The connection timed out from inactivity. (http://serverUrl)") { "opinion": "USERNAME_OPINION_OK" } { "opinion": "USERNAME_OPINION_BAD" } { "opinion": "USERNAME_OPINION_BAD" } { "opinion": "USERNAME_OPINION_BAD" } Note: on linux mashine the client code works perfectly (tested and approved), while I work on windows 11 and using Visual Studio 2022
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
Cosmic Centipede
Cosmic CentipedeOP9mo ago
@TeBeCo we are using .NET 8
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
Cosmic Centipede
Cosmic CentipedeOP9mo ago
The server is idle, and all of the requests happen sequentially
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
Cosmic Centipede
Cosmic CentipedeOP9mo ago
That's the default for the back-end, which is based on Tonic (Rust)
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
Cosmic Centipede
Cosmic CentipedeOP9mo ago
Got it
Cosmic Centipede
Cosmic CentipedeOP9mo ago
Nvm, the server isn't over QUIC, the highest it does is HTTP/2, not sure why .NET is trying to communicate over it. Not sure how to prohibit it from doing so either, as setting request protocol versions through HttpClient doesn't have an effect.
No description
Cosmic Centipede
Cosmic CentipedeOP9mo ago
@TeBeCo if you are interested, using .NET 6, the error does not occur, so the short-term solution, we will just use .NET 6 on this project and not .NET 7-8 (issue also is on the 7th)
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
hlk
hlk9mo ago
Repro is difficult, we seem to have traced the issue to some bad interaction between the Caddy proxy server and the Windows implementation of HttpClient Running Kestrel locally is OK, so is running the server locally when a direct connection can be made (localhost:xxxx)
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
hlk
hlk9mo ago
We were trying to get some minimal reproduction sample going
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
hlk
hlk9mo ago
Caddy supports HTTP/3 and I think it announces it, although the underlying proxied application might not, as is the case for our back-end, as Tonic only does HTTP/2
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
hlk
hlk9mo ago
{
servers {
protocols h1 h2
}
}

rpc.project.net {
header -Alt-Svc
reverse_proxy h2c://127.0.0.1:50051
}
{
servers {
protocols h1 h2
}
}

rpc.project.net {
header -Alt-Svc
reverse_proxy h2c://127.0.0.1:50051
}
Disabling the Alt-Svc header on that specific resource fixes the issue
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
hlk
hlk9mo ago
- for a header config in Caddy means to delete the header
hlk
hlk9mo ago
header (Caddyfile directive) - Caddy Documentation
Caddy is a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
hlk
hlk9mo ago
It does not, the configuration is valid. Simply setting server protocols to h1 h2 isn't enough to stop this from happening, we had that set before the issue was resolved. header -Alt-Svc seems to be necessary.
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
hlk
hlk9mo ago
Well it works for us now with the header stripped, but we don't know what's causing it, just that it's not our problem We'll try filing a bug report on the dotnet repo sometime later today
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
hlk
hlk9mo ago
Will do
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server