runtime: Subsequent Grpc calls with WinHttpHandler to an IIS hosted service fail

Description

I’m trying to call a Grpc service hosted in IIS over http2 from NetFramework app. After reading the relevant docs(supported platforms) and issues (https://github.com/dotnet/aspnetcore/issues/9020, https://github.com/dotnet/core/issues/5713) I understand that this should be possible if I’m using Win11/WinServer2022 with the pre release version of the System.Net.Http.WinHttpHandler nuget package (in my case 6.0.0-rc.1.21451.13).

Unfortunately this seems not to be the case, as only the first call to the service succeeds and any subsequent call fails with Status(StatusCode="Cancelled", Detail="No grpc-status found on response. Using gRPC with WinHttp has Windows and package version requirements. See https://aka.ms/aspnet/grpc/netstandard for details.").

Things get even stranger when I tested combining calls made with the NetCore’s SocketsHttpHandler. A call with the WinHttpHandler will fail no matter whether the first call to the service was made with WinHttp or Sockets, and it appears that the problem is somehow triggered by the state of the IIS application as restarting the host resets the issue(restarting the client has no effect). Furthermore even after the WinHttp call has failed one can successfully call the service with the Sockets handler from the same process.

Here is a table with the different setups

Client Server Result
WinHttp IIS ❌ Fail
WinHttp Kestrel ✔️ Succeeds
Sockets IIS ✔️ Succeeds
Sockets Kestrel ✔️ Succeeds

Reproduction Steps

I’ve created a minimal project that reproduces the problem - https://github.com/angelyordanov/grpc-iis-winhttp-sample

  1. Start the GrpcService with the IISExpress profile
  2. Start either one of the console apps

Expected behavior

There should be no exceptions and all grpc calls should succeed.

Actual behavior

The second call made with the WinHttpHandler always fails.

Regression?

No

Known Workarounds

No

Configuration

dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.401
 Commit:    4bef5f3dbf

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.401\

Other information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (15 by maintainers)

Most upvoted comments

Reopening to track 6.0.x backport. This is a bug blocking .NET Framework gRPC developer workflow in Visual Studio + IIS Express.

This exception message is coming from grpc-dotnet, I recommend to open an issue on that repo, unless @JamesNK can confirm that this is something we should address in WinHttpHandler.