Drees
Drees

Reputation: 720

gRPc (C#) support for IIS Windows Server 2019

I am working on converting some of my WCF projects. Is it possible to connect gRPC to Windows Server 2019 yet? I’ve read on GitHub repository that it works for 2022+; however the issue was made a couple of years ago.

To start I used the default project that comes with the gRPC Service project in visual studio (Greeter).


————-
Web service settings
————-

using Server;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGrpc();

var app = builder.Build();
app.MapGrpcService<GreeterService>();

app.Run();

// kestrel settings in appsettings set to Http1AndHttp2

————-
Proto
—————
syntax = "proto3";

package greet;

// The greeting service definition.
service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply);
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings
message HelloReply {
  string message = 1;
}


——————-
service
——————-

using System.Threading.Tasks;
using Greet;
using Grpc.Core;
using Microsoft.Extensions.Logging;

namespace Server
{
    public class GreeterService : Greeter.GreeterBase
    {
        private readonly ILogger _logger;

        public GreeterService(ILoggerFactory loggerFactory)
        {
            _logger = loggerFactory.CreateLogger<GreeterService>();
        }

        public override Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)
        {
            _logger.LogInformation($"Sending hello to {request.Name}");
            return Task.FromResult(new HelloReply { Message = "Hello " + request.Name });
        }
    }
}

I created websites on both local and remote machine and trying to test with Postman. Locally it works correctly and I get a response. I have https set up on both local and remote and certifications seem fine.

However running Postman on the remote machine (Windows Server 2019); I get a “13 INTERNAL” error.

I’ve checked both settings for IIS and made sure ASPNET versions match, but no such luck.

Postman:

Local Machine:

Remote:

Like I said I can access both https://localhost/WSGreeter on the browser for local and remote, both work fine; no issues.

My thoughts are that it still has to do with Windows Server 2019.

Wondering if anyone had came across a solution to get it working for this version of Windows Server. If so; can you provide what you did?

Upvotes: 0

Views: 70

Answers (1)

Jalpa Panchal
Jalpa Panchal

Reputation: 12789

As mentioned in the official document gRPC supported on Windows 11 Build 22000 or later, Windows Server 2022 Build 20348 or later.

https://learn.microsoft.com/en-us/aspnet/core/grpc/aspnetcore?view=aspnetcore-8.0&tabs=visual-studio#iis

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/protocols?view=aspnetcore-9.0#advanced-http2-features-to-support-grpc

If you are interested in the reverse proxy you could install the ARR and URL rewrite and set the reverse proxy rule.

https://techcommunity.microsoft.com/blog/iis-support-blog/setup-iis-with-url-rewrite-as-a-reverse-proxy-for-real-world-apps/846222

Upvotes: 0

Related Questions