question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERR_CONNECTION_REFUSED with Example Blazor Project gRPC Web Server

See original GitHub issue

What 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:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tenglandctcommented, Jan 23, 2022

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:

"Kestrel": {
    "EndpointDefaults": {
      "Protocols": "Http2"
    }
  },

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)

0reactions
hmihcommented, Apr 10, 2023

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use gRPC-Web with Blazor WebAssembly on App ...
NET server app hosted on App Service using gRPC-Web middleware ... Open Visual Studio and Create a new project and search for Blazor...
Read more >
A new experiment: Call .NET gRPC services from the ...
I've been trying to get a Grpc Server to Stream to a Blazor WebAssembly application without luck. The examples for Blazer only show...
Read more >
Asp.net: 'application/grpc-web' is not supported
I had Asp.net core and gRPC working on the browser...but now I get: info: Grpc.AspNetCore.Server.ServerCallHandler[2] Request content-type of ' ...
Read more >
How to Integrate gRPC Service in a Blazor Datagrid ...
REST provides guidelines to build Web API's over HTTP1 where as gRPC enforces messaging format between client and server over HTTP2; REST uses ......
Read more >
Using gRPC-Web with Blazor WebAssembly - Steve Sanderson
If you're hosting a Blazor WebAssembly application on ASP.NET Core server, then by default you have three projects: client, server, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found