ERR_CONNECTION_REFUSED with Example Blazor Project gRPC Web Server
See original GitHub issueWhat version of gRPC and what language are you using?
Grpc.AspNetCore = 2.41.0 Grpc.AspNetCore.Web = 2.41.0
What operating system (Linux, Windows,…) and version?
MacOS 11.2.3
What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info
)
Version: 6.0.101
What did you do?
Ran server project and connected to the endpoint with RPC client (BloomRPC) using both gRPC-web and gRPC
What did you expect to see?
The same, successful response using both protocols
What did you see instead?
Using BloomRPC I tested the gRPC GetWeatherForecasts endpoint using straight gRPC and it worked. Used gRPC-web and it errored with the following response:
{ “error”: “full url: http://0.0.0.0:5000/weather.WeatherForecasts/GetWeatherForecasts, code: 2, err: Http response at 400 or 500 level” }
with the status ERR_CONNECTION_REFUSED
I have also replicated the same issue using the client application, running locally, as well as BloomRPC
Anything else we should know about your project / environment?
I have also built a PoC project separately from the test project and am experiencing the same issue but with different details of implementation.
From what I have researched around the issue, I would guess it’s issue specific to MacOS (possibly to do with the changes you need to make to the server as described here: https://docs.microsoft.com/en-us/aspnet/core/grpc/troubleshoot?view=aspnetcore-3.0#unable-to-start-aspnet-core-grpc-app-on-macos), which is different to CORS or url related issues as described here: https://github.com/grpc/grpc-dotnet/issues/1126
As per above Microsoft docs, I added the following to the ConfigureWebHostDefaults in Server/Program.cs - all other code is unchanged from latest repo version (7d081d7c2682c792971d851e9e88d11a8728a2aa)
webBuilder.UseKestrel(options => { // Setup a HTTP/2 endpoint without TLS. options.ListenLocalhost(5000, o => o.Protocols = HttpProtocols.Http2); });
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
I tried again after updating to 12.1 and it also failed, however, I did a bit more looking around at what could be different between the 2 projects and found that I had also added in the following block into appsettings.json:
Removing that, as well as the Kestrel web host config block, fixed the issue for me.
I agree it looks like the workaround either needs updating or removing with a caveat about TLS on macOS in general (as I could not build the site whilst still trying to serve to an https address as well as the http one)
AAAAAAA Oh my god, I’ve been banging my head against the wall for 2 days on a stupid CORS preflight headers issue and removing the
Kestrel
configuration worked for me. The setup of my project is grpc-web server and blazor wasm grpc-web client. I’m on a MacOS M1 13 with everything latest. The official Microsoft documentation does not refer to this issue and it’s been a huge pain in the ass. Thank you @tenglandct . I’m also referring #998 (same error) because maybe some lonely search result explorer will find this fix.