I developed a GRPC service using .NET 8. The service functions properly when run locally. However, when I deploy it to Azure Container Apps service and attempt to invoke it from another app with Dapr, I encounter the following error:
initial http2 frame from server is not a settings frame: *http2.GoAwayFrame
The service code:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddApplicationInsightsTelemetry();
builder.Services.AddGrpc();
var app = builder.Build();
app.MapGrpcService<MyService>();
app.MapGet("/", () => "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
app.Run();
The Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /src
COPY ["./MyServiceApp/MyServiceApp.csproj", "./MyServiceApp/MyServiceApp.csproj"]
RUN dotnet restore "./MyServiceApp/MyServiceApp.csproj"
COPY . .
WORKDIR "/src/MyServiceApp"
RUN dotnet restore "MyServiceApp.csproj"
RUN dotnet publish "MyServiceApp.csproj" -c Release -o /app/out /p:UseAppHost=false
FROM mcr.microsoft.com/dotnet/aspnet:8.0
EXPOSE 8080
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "MyServiceApp.dll"]
The code used from the second app:
var daprPort = Environment.GetEnvironmentVariable("DAPR_GRPC_PORT");
var url = string.IsNullOrEmpty(daprPort) ? this.myServiceUrl : $"http://localhost:{daprPort}";
this.logger.LogInformation("Using service url {Url}", url);
using var channel = GrpcChannel.ForAddress(url);
var client = new MyService.MyServiceClient(channel);
var myRequest = new MyRequest { DeviceId = request.DeviceId.ToString() };
var metadata = new Metadata { { "dapr-app-id", "myapp" } };
var response = await client.DoSomethingAsync(myRequest, metadata, cancellationToken: cancellationToken);
The bicep fragment for the service app:
ingress: {
targetPort: 8080
external: false
transport: 'http2'
}
dapr: {
enabled: true
appId: 'myapp'
appPort: 8080
appProtocol: 'grpc'
enableApiLogging: true
logLevel: 'debug'
}