System.IO.IOException with a .NET gRPC Project on Mac

Hey everyone,


I created a new gRPC project with Visual Studio on a Mac and ran into the following error when trying to run it:

System.IO.IOException
...
http/2 over tls is not supported on macos due to missing alpn support

It turns out that Kestrel does not support HTTP/2 with TLS on MacOS. In order to get around it we end up having to configure it to not use TLS.

In program.cs, add the lines below with your HTTP port (e.g. 20257):

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.ConfigureKestrel(options =>
{
    // Setup a HTTP/2 endpoint without TLS.
    options.ListenLocalhost(20257, o => o.Protocols =
        HttpProtocols.Http2);
});

Thanks to the following links for the info:

Leave a comment