grpc-dotnet
grpc-dotnet copied to clipboard
Hosting gRPC on IIS - Trailers are not supported for this response. The server may not support gRPC.
I have a sample ASP.NET Core 8 application, using the default gRPC template , added Serilog and "Grpc.AspNetCore.Server.Reflection, all works fine locally. Using the default greeter service sample.
I am trying to verify that I can deploy this to my demo server.
But, deploying to IIS (Windows 10 machine version 22H2), IIS 10.0.19041.1 does not work, I get this log:
2023-08-27 17:01:27.632 +02:00 [INF] Request finished HTTP/2 POST https://grpc.secure.nu/greet.Greeter/SayHello - 200 null application/grpc 2.6704ms
2023-08-27 17:01:28.929 +02:00 [INF] Request starting HTTP/2 POST https://grpc.secure.nu/greet.Greeter/SayHello - application/grpc null
2023-08-27 17:01:28.930 +02:00 [DBG] 3 candidate(s) found for the request path '/greet.Greeter/SayHello'
2023-08-27 17:01:28.930 +02:00 [DBG] Endpoint 'gRPC - /greet.Greeter/SayHello' with route pattern '/greet.Greeter/SayHello' is valid for the request path '/greet.Greeter/SayHello'
2023-08-27 17:01:28.930 +02:00 [DBG] Endpoint 'gRPC - Unimplemented method for greet.Greeter' with route pattern 'greet.Greeter/{unimplementedMethod:grpcunimplemented}' is valid for the request path '/greet.Greeter/SayHello'
2023-08-27 17:01:28.930 +02:00 [DBG] Endpoint 'gRPC - Unimplemented service' with route pattern '{unimplementedService}/{unimplementedMethod:grpcunimplemented}' is valid for the request path '/greet.Greeter/SayHello'
2023-08-27 17:01:28.930 +02:00 [DBG] Request matched endpoint 'gRPC - /greet.Greeter/SayHello'
2023-08-27 17:01:28.930 +02:00 [DBG] The endpoint does not specify the IRequestSizeLimitMetadata.
2023-08-27 17:01:28.930 +02:00 [INF] Executing endpoint 'gRPC - /greet.Greeter/SayHello'
2023-08-27 17:01:28.930 +02:00 [DBG] Reading message.
2023-08-27 17:01:28.930 +02:00 [DBG] Sending message.
2023-08-27 17:01:28.930 +02:00 [ERR] Error when executing service method 'SayHello'.
System.InvalidOperationException: Trailers are not supported for this response. The server may not support gRPC.
at Grpc.AspNetCore.Server.Internal.GrpcProtocolHelpers.GetTrailersDestination(HttpResponse response)
at Grpc.AspNetCore.Server.Internal.HttpResponseExtensions.ConsolidateTrailers(HttpResponse httpResponse, HttpContextServerCallContext context)
at Grpc.AspNetCore.Server.Internal.HttpContextServerCallContext.EndCallCore()
at Grpc.AspNetCore.Server.Internal.HttpContextServerCallContext.EndCallAsync()
at Grpc.AspNetCore.Server.Internal.CallHandlers.ServerCallHandlerBase`3.HandleCallAsync(HttpContext httpContext)
2023-08-27 17:01:28.930 +02:00 [INF] Executed endpoint 'gRPC - /greet.Greeter/SayHello'
2023-08-27 17:01:28.930 +02:00 [ERR] HTTP POST /greet.Greeter/SayHello responded 500 in 0.6082 ms
System.InvalidOperationException: Trailers are not supported for this response. The server may not support gRPC.
at Grpc.AspNetCore.Server.Internal.GrpcProtocolHelpers.GetTrailersDestination(HttpResponse response)
at Grpc.AspNetCore.Server.Internal.HttpResponseExtensions.ConsolidateTrailers(HttpResponse httpResponse, HttpContextServerCallContext context)
at Grpc.AspNetCore.Server.Internal.HttpContextServerCallContext.ProcessHandlerError(Exception ex, String method)
at Grpc.AspNetCore.Server.Internal.HttpContextServerCallContext.ProcessHandlerErrorAsync(Exception ex, String method)
at Grpc.AspNetCore.Server.Internal.CallHandlers.ServerCallHandlerBase`3.HandleCallAsync(HttpContext httpContext)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext)
another example when doing a reflection call:
2023-08-27 16:52:08.697 +02:00 [DBG] Hosting starting
2023-08-27 16:52:08.772 +02:00 [DBG] Loaded hosting startup assembly minimal.grpc.secure.nu
2023-08-27 16:52:08.773 +02:00 [INF] Application started. Press Ctrl+C to shut down.
2023-08-27 16:52:08.774 +02:00 [INF] Hosting environment: Production
2023-08-27 16:52:08.774 +02:00 [INF] Content root path: C:\inetpub\grpc.secure.nu
2023-08-27 16:52:08.774 +02:00 [DBG] Hosting started
2023-08-27 16:52:08.793 +02:00 [INF] Request starting HTTP/2 POST https://grpc.secure.nu/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo - application/grpc null
2023-08-27 16:52:08.798 +02:00 [DBG] Wildcard detected, all requests with hosts will be allowed.
2023-08-27 16:52:08.850 +02:00 [DBG] 3 candidate(s) found for the request path '/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo'
2023-08-27 16:52:08.852 +02:00 [DBG] Endpoint 'gRPC - /grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo' with route pattern '/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo' is valid for the request path '/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo'
2023-08-27 16:52:08.853 +02:00 [DBG] Endpoint 'gRPC - Unimplemented method for grpc.reflection.v1alpha.ServerReflection' with route pattern 'grpc.reflection.v1alpha.ServerReflection/{unimplementedMethod:grpcunimplemented}' is valid for the request path '/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo'
2023-08-27 16:52:08.853 +02:00 [DBG] Endpoint 'gRPC - Unimplemented service' with route pattern '{unimplementedService}/{unimplementedMethod:grpcunimplemented}' is valid for the request path '/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo'
2023-08-27 16:52:08.853 +02:00 [DBG] Request matched endpoint 'gRPC - /grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo'
2023-08-27 16:52:08.854 +02:00 [DBG] The endpoint does not specify the IRequestSizeLimitMetadata.
2023-08-27 16:52:08.860 +02:00 [INF] Executing endpoint 'gRPC - /grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo'
2023-08-27 16:52:08.922 +02:00 [DBG] Reading message.
2023-08-27 16:52:08.935 +02:00 [DBG] Sending message.
2023-08-27 16:52:08.942 +02:00 [DBG] Reading message.
2023-08-27 16:52:08.944 +02:00 [ERR] Error when executing service method 'ServerReflectionInfo'.
System.InvalidOperationException: Trailers are not supported for this response. The server may not support gRPC.
at Grpc.AspNetCore.Server.Internal.GrpcProtocolHelpers.GetTrailersDestination(HttpResponse response)
at Grpc.AspNetCore.Server.Internal.HttpResponseExtensions.ConsolidateTrailers(HttpResponse httpResponse, HttpContextServerCallContext context)
at Grpc.AspNetCore.Server.Internal.HttpContextServerCallContext.EndCallCore()
at Grpc.AspNetCore.Server.Internal.HttpContextServerCallContext.EndCallAsync()
at Grpc.AspNetCore.Server.Internal.CallHandlers.ServerCallHandlerBase`3.HandleCallAsync(HttpContext httpContext)
When I make a console client, I get this exception: 'No grpc-status found on response'
Facts:
- Window 10 machine
- IIS 19045.3324
- .NET 8 (preview latest, Microsoft.NETCore.App 8.0.0-preview.7.23375.6)
- Other sites using HTTP/2 works fine
- Valid HTTPS certificate.
- I am using Postman to send the requests
- Hosted in a Virtual Machine, no load balancer or proxies involved.
- IIS Managed pipeline Integrated
So, my question, if anyone have a suggestion how to troubleshoot this? Works fine locally on IIS Express and Kestrel.