gRPC has an issue when Kestrel set to Http1AndHttp2 with unsecure urls.
See original GitHub issuegRPC has an issue when Kestrel set to Http1AndHttp2 with unsecure urls.
This has to do with unsecure URLs. We are using unsecure URLs because we want to host the gRPC services inside Kubernetes cluster with HTTP. We will support HTTPS at the load balancer and offload the TLS. Additionally, we have a development team that has a mix of Windows and Macs and want to support development on the Mac and cannot use HTTPS with gRPC at the moment due to missing ALPN support on the Mac.
Reference: Unable to start AspNet Core gRPC on Mac OS
We are trying to host both gRPC services and would like to host MapGet endpoints. Interestingly, the gRPC template does exactly this. When you use the sample out-of-the-box, it works. But when we change to use an unsecure applicationUrl in launchSettings things stop working.
The MapGet(“/”) fails with an unsecure URL (ex. http://localhost:5000). We are able to get the MapGet(“/”) to work when we change the protocol from Http2 to Http1AndHttp2. Conversely, our gRPC services fails when Kestrel supports both Http1AndHttp2 with an unsecure applicationUrl.
Scenario #1 - Secure URL (https://localhost:5001), Http2 Protocol MapGet Succeeds, gRPC Succeeds
Scenario #2 - Unsecure URL (http://localhost:5000), Http2 Protocol MapGet Fails, gRPC Succeeds
Scenario #3 - Unsecure URL (http://localhost:5000), Http1AndHttp2 Protocol MapGet Succeeds, gRPC Fails
What version of gRPC and what language are you using?
Testing with 2.29.0 and 2.30-pre1
What operating system (Linux, Windows,…) and version?
Windows 10
What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info
)
.NET Core SDK (reflecting any global.json): Version: 3.1.301 Commit: 7feb845744
Runtime Environment: OS Name: Windows OS Version: 10.0.20161 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.301\
Host (useful for support): Version: 3.1.5 Commit: 65cd789777
.NET Core SDKs installed: 2.1.806 [C:\Program Files\dotnet\sdk] 2.2.207 [C:\Program Files\dotnet\sdk] 2.2.402 [C:\Program Files\dotnet\sdk] 3.0.103 [C:\Program Files\dotnet\sdk] 3.1.301 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0-preview9.19424.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.0-preview3.19555.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0-preview9-19423-09 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.0-preview3.19553.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0-preview9-19423-09 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.0-preview3.19553.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
What did you do?
Start with ASP.NET Core gRPC template.
dotnet new grpc -o HelloGrpc
Change launchSettings to unsecure URL breaks MapGet
"profiles": {
"DeviceQuery.Host": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Change Kestrel protocols in appsettings.json breaks gRPC “Kestrel”: { “EndpointDefaults”: { “Protocols”: “Http1AndHttp2” } },
What did you expect to see?
MapGet should just work when using an insecure URL and protocol Http2. gRPC should just work when using an insecure URL and protocol Http1AndHttp2
What did you see instead?
We see two failures, one with MapGet and one with gRPC.
Anything else we should know about your project / environment?
We are trying to get this working on Windows first, then on the Mac.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top GitHub Comments
This is an expected situation.
Http1AndHttp2 requires TLS for ALPN protocol negotiation. You either need separate ports for HTTP/1.1 and HTTP/2, or use TLS.
See https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-3.1#listenoptionsprotocols
hi @ChiefInnovator I have exact same issue as you described here. Do you have any workaround for this? It’s really an issue for my end if MapGet can’t work on Unsecure URL and Http2 Protocol. Thanks and regards.