0

Given an Azure Virtual Network with two subnets, one with an Azure App Service that has a gRPC client and the other an Azure Container App with a gRPC server, what is the correct URL and port to allow message passing?

The error is:

Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="Error connecting to subchannel.", DebugException="System.Net.Sockets.SocketException: Connection timed out")

The application works locally with "http://localhost:5000". The Container App has an Application URL that I can resolve with 'nslookup' when I SSH into the App Service container as there's a Private DNS for the Container App Environment. The Log Stream for the Container App reports:

Now listening on: http://[::]:5000

Setting up the client channel:

var channel = GrpcChannel.ForAddress("http://myapp.graybay-2091cc5a.uksouth.azurecontainerapps.io:5000");

Setting up the server:

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.ConfigureKestrel(options =>
{
    options.Listen(IPAddress.Any, 5000, o => o.Protocols = HttpProtocols.Http2);
    options.ListenLocalhost(5000, o => o.Protocols = HttpProtocols.Http2);
});

var app = builder.Build();

app.MapGrpcService<HeartbeatService>();

The client crashes when it goes over the maximum retries to connect to the server.

Why can't the client connect to the subchannel?

Boggin
  • 3,251
  • 3
  • 33
  • 48

1 Answers1

1

use

var channel = GrpcChannel.ForAddress("https://myapp.graybay-2091cc5a.uksouth.azurecontainerapps.io");

To use http://myapp.graybay-.... you need to set allowInsecure: true on your app.

You also must have transport: http2 on the app for grpc to work.

ahmelsayed
  • 7,125
  • 3
  • 28
  • 40
  • Already, transport is Http2, and allowInsecure is true. Removing the port number from the URL causes the app to crash. Setting the port number explicitly to 443 has helped. Now I've a 'Service unimplemented' error although the code has worked running locally. Thank you, I'm further on now. – Boggin May 16 '23 at 23:32