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?
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.