question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Grpc.Web - Hosting issues under IIS or Application Service Plan

See original GitHub issue

We’ve already got some gRPC clients (Dotnet Core Worker Service) running using reverse proxies and Kestrel and this works fine. But we are keen to switch to App Service Plans (or even a VM and IIS) as this is the business standard approach. As such, this post was a great bit of news and so we quickly set about converting the start up in both client and server to support it.

Having deployed to both VM running IIS and then an Application Service plan we keep getting met with the same error message, I’m fairly sure it’s to do with IIS configuration but I can’t find anything that helps with the issue.

A static page on the application can be displayed and proves the system is running and accepting requests, so it is a purely gRPC issue as far as I can tell.

The VM is running Server 2016 and Dotnet Core 3.1.1 Hosting Bundle and has the latest Windows updates installed, the application was deployed as an In-Process set up. The application service plan we tried was the standard Azure Application Service Plan (Windows based), it returned the same client error as the VM.

gRPC in Visual Studio Debug gives:

Status(StatusCode=Internal, Detail=”Content-Type ‘application/grpc-web-text’ is not supported.”)

The logs from the IIS server show the following:

warn: Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository[50] Using an in-memory repository. Keys will not be persisted to storage.

warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[59] Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data will be unavailable when application exits.

warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35] No XML encryptor configured. Key {d496f657-222b-4e28-8648-a2619138201f} may be persisted to storage in unencrypted form.

info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down.

info: Microsoft.Hosting.Lifetime[0] Hosting environment: Production

info: Microsoft.Hosting.Lifetime[0] Content root path:

fail: Grpc.AspNetCore.Server.ServerCallHandler[6] Error when executing service method ‘AuthenticateApp’.

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.ServerCallHandlerBase3.<HandleCallAsync>g__AwaitHandleCall|17_0(HttpContextServerCallContext serverCallContext, Method2 method, Task handleCall)

fail: Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer[2] Connection ID “7566047384183026471”, Request ID “8000b328-0002-6900-b63f-84710c7967bb”: An unhandled exception was thrown by the application.

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.ServerCallHandlerBase3.<HandleCallAsync>g__AwaitHandleCall|17_0(HttpContextServerCallContext serverCallContext, Method2 method, Task handleCall) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.g__AwaitMatcher|8_0(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task1 matcherTask) at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT1.ProcessRequestAsync()

fail: Grpc.AspNetCore.Server.ServerCallHandler[6] Error when executing service method ‘AuthenticateApp’.

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.g__AwaitHandleCall|17_0(HttpContextServerCallContext serverCallCon

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:34 (14 by maintainers)

github_iconTop GitHub Comments

3reactions
JamesNKcommented, Feb 7, 2020

Your problem is UseGrpcWeb needs to be between UseRouting and UseEndpoints.

1reaction
AnthonyGiretticommented, Feb 11, 2020

I finally made it work. My app was running with .NET Core 3.1 runtime which seems not working with Linux AppService.

portal3

With a Linux AppService the app (it’s a docker container Behring the scène not managed by me) just doesn’t start:

unnamed

So I downgraded to .NET Core 3.0 and deployed on a Windows AppService and it works fine now.

It was not a CORS issue, browsers raise an unexpected CORS error when the remote API crashes, because CORS headers are not sent.

Demo here: https://anthonygiretti.blob.core.windows.net/grpcwebdemo/index.html (The Angular 8 app is deployed in static website.)

About my HttpClient which failed to call your AppService I never found the solution, I just started a new project from scratch and it works fine now.

Thanks for your support and I hope this will help people

Read more comments on GitHub >

github_iconTop Results From Across the Web

.NET gRPC on IIS Windows Server 2019 - or if Kestrel can ...
I have a production server running Windows Server 2019 and an old ASP.NET site on IIS, along with a few other subsites (sub-domains)...
Read more >
A new experiment: Call .NET gRPC services from the ...
Host ASP.NET Core gRPC apps in IIS and Azure App Service – Some servers, such as IIS and Azure App Service, currently can't...
Read more >
Can you use gRPC/gRPC-Web to communicate between ...
Azure App Services uses IIS/Windows/Http.sys. Http.sys is baked into the OS and doesn't fully support HTTP/2 trailing headers that gRPC depends ...
Read more >
gRPC-Web for .NET now available | Windows Apps and more
Host ASP.NET Core gRPC apps in IIS and Azure App Service – Some servers, such as IIS and Azure App Service, currently can't...
Read more >
Deploying a .NET gRPC Server on Azure App Service
In this article we are going to be deploying a gRPC web service written in .NET to an Azure App Service. We will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found