How can I deploy GRPC app into IIS with Kestrel

105 Views Asked by At

I need to deploy GRPC in Windows server 2019, I use .Net 6 and add Kestrel in the BuilderService, but when I publish this in IIS doesn't work, this is my code

builder.Services.AddGrpc();

builder.Services.Configure<KestrelServerOptions>(opt =>
{
    opt.ListenAnyIP(5001, listenOpt =>
    {
        listenOpt.Protocols = HttpProtocols.Http2;
    });
});

builder.WebHost.UseKestrel();

and this is my client

try
{
    Console.WriteLine("Hello, World!");
    using var channel = GrpcChannel.ForAddress("http://localhost:5001");
    var client = new Greeter.GreeterClient(channel);
    var reply = await client.SayHelloAsync(new HelloRequest { Name = "Mauricio" });
    Console.WriteLine($"Greeting {reply.Message}");
    Console.ReadKey();
}catch(Exception ex)
{
    Console.WriteLine(ex.ToString());
}

If i used the iis port bundle I received this exception

An HTTP/2 connection could not be established because the server did not complete the HTTP/2 handshake.

But if I used 5001 port I received this exception

Error connecting to subchannel. System.Net.Sockets.SocketException: No se puede establecer una conexión ya que el equipo de destino denegó expresamente dicha conexión.

I have already installed Dotnet Hosting 7 and I have activated http/2 too.

If any know how I can to deploy this, please help me.

0

There are 0 best solutions below

Related Questions in GRPC-C#