C#
Grpc.AspNetCore" Version="2.25.0" and whatever GrpcDotNetPackageVersion is set to in the sample projects for this repo
MacOs Mojave and ubuntu 16.04
dotnet --info)Mac:
â–¶ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100
Commit: 04339c3a26
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.14
OS Platform: Darwin
RID: osx.10.14-x64
Base Path: /usr/local/share/dotnet/sdk/3.0.100/
Host (useful for support):
Version: 3.0.0
Commit: 7d57652f33
.NET Core SDKs installed:
1.0.4 [/usr/local/share/dotnet/sdk]
2.0.0 [/usr/local/share/dotnet/sdk]
2.1.200 [/usr/local/share/dotnet/sdk]
2.1.505 [/usr/local/share/dotnet/sdk]
2.2.105 [/usr/local/share/dotnet/sdk]
3.0.100-preview3-010431 [/usr/local/share/dotnet/sdk]
3.0.100 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview3-19153-02 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview3-27503-5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Linux
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100
Commit: 04339c3a26
Runtime Environment:
OS Name: ubuntu
OS Version: 16.04
OS Platform: Linux
RID: ubuntu.16.04-x64
Base Path: /usr/share/dotnet/sdk/3.0.100/
Host (useful for support):
Version: 3.0.0
Commit: 95a0a61858
.NET Core SDKs installed:
3.0.100 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
git clone https://github.com/grpc/grpc-dotnet.git
cd grpc-dotnet/examples/Tester/
dotnet test
all of the tests pass
the unit tests pass and the functional tests fail with Grpc.Core.RpcException : Status(StatusCode=Internal, Detail="Bad gRPC response. Response protocol downgraded to HTTP/1.1.").
For example:
X SayHelloClientStreamingTest [120ms]
Error Message:
Grpc.Core.RpcException : Status(StatusCode=Internal, Detail="Bad gRPC response. Response protocol downgraded to HTTP/1.1.")
Stack Trace:
at Tests.FunctionalTests.GreeterServiceTests.SayHelloClientStreamingTest() in /home/vagrant/grpc-dotnet/examples/Tester/Tests/FunctionalTests/GreeterServiceTests.cs:line 62
at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaitable)
at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
at NUnit.Framework.Internal.Commands.TestMethodCommand.RunTestMethod(TestExecutionContext context)
at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context)
at NUnit.Framework.Internal.Execution.SimpleWorkItem.PerformWork()
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
See TROUBLESHOOTING.md for how to diagnose problems better.
Thanks for the clear description of the issue. The underlying problem is in the ASP.NET Core TestServer. I'll see if I can fix it there.
In the meantime there is a workaround here - https://github.com/grpc/grpc-dotnet/pull/649
Thanks for the quick response and workaround!
How to use the workaround with IServiceCollection.AddGrpcClient?
There is old example of using gRPC client with functional test server in the history of this repo - https://github.com/grpc/grpc-dotnet/blob/04c04d4c6070fc6e389abd0d8da9c12919e6ad6d/testassets/FunctionalTestsWebsite/Startup.cs#L60
You will need to get the source code at that point in time and copy a number of types:
I believe the TestServer needs to be added to the test server services as well.
When will the TestServer be fixed?
For a workaround look here: #654
There are anyone who didn't want to create custom fixture class.
public static class WebApplicationFactoryHelper
{
public static GrpcChannel CreateGrpcChannel(this WebApplicationFactory<Startup> factory)
{
var client = factory.CreateDefaultClient(new ResponseVersionHandler());
return GrpcChannel.ForAddress(client.BaseAddress, new GrpcChannelOptions
{
HttpClient = client
});
}
private class ResponseVersionHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
CancellationToken cancellationToken)
{
var response = await base.SendAsync(request, cancellationToken);
response.Version = request.Version;
return response;
}
}
}
and use like this.
[Fact]
public async Task Test() {
var client = new Greeter.GreeterClient(_factory.CreateGrpcChannel());
// Do something...
}
Most helpful comment
There are anyone who didn't want to create custom fixture class.
and use like this.