I have a gRPC server implemented in .Net Core that I would like to contact with a console app running in .Net Framework.
Here is a working repo of the issue:
https://github.com/q-bertsuit/grpc-framework-core-issue
The following .Net Core Client works fine:
class Program
{
static async Task Main(string[] args)
{
var input = new MyModel();
var channel = GrpcChannel.ForAddress("https://localhost:5001");
var client = new Test.TestClient(channel);
var reply = await client.SetTestAsync(input);
Console.ReadLine();
}
}
The following .Net Framework client throws an exception:
class Program
{
static void Main(string[] args)
{
Channel channel = new Channel("https://localhost:5001", ChannelCredentials.Insecure);
var client = new Test.TestClient(channel);
MyModel request = new MyModel();
var reply = client.SetTest(request);
channel.ShutdownAsync().Wait();
Console.ReadLine();
}
}
I get the following exception when sending the request:
Grpc.Core.RpcException: 'Status(StatusCode="Unavailable", Detail="DNS resolution failed for service: https://localhost:5001", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1600333768.055000000","description":"Resolver transient failure","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\resolving_lb_policy.cc","file_line":215,"referenced_errors":[{"created":"@1600333768.055000000","description":"DNS resolution failed for service: https://localhost:5001","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\resolver\dns\c_ares\dns_resolver_ares.cc","file_line":378,"grpc_status":14,"referenced_errors":[{"created":"@1600333768.055000000","description":"C-ares status is not ARES_SUCCESS qtype=A name=https://localhost:5001 is_balancer=0: Could not contact DNS servers","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\resolver\dns\c_ares\grpc_ares_wrapper.cc","file_line":287,"referenced_errors":[{"created":"@1600333768.055000000","description":"C-ares status is not ARES_SUCCESS qtype=AAAA name=https://localhost:5001 is_balancer=0: Could not contact DNS servers","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\resolver\dns\c_ares\grpc_ares_wrapper.cc","file_line":287}]}]}]}")'
On the server I get this error:
dbug: Microsoft.AspNetCore.Server.Kestrel[17] Connection id "0HM2QU64LCR9J" bad request data: "Unrecognized HTTP version: 'HTTP/2.0'" Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Unrecognized HTTP version: 'HTTP/2.0' at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpParser
1.RejectUnknownVersion(Byte* version, Int32 length) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpParser
1.ParseRequestLine(TRequestHandler handler, Byte* data, Int32 length) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpParser1.ParseRequestLine(TRequestHandler handler, ReadOnlySequence
1& buffer, SequencePosition& consumed, SequencePosition& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpParser1.Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.IHttpParser<TRequestHandler>.ParseRequestLine(TRequestHandler handler, ReadOnlySequence
1& buffer, SequencePosition& consumed, SequencePosition& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.TakeStartLine(ReadOnlySequence1& buffer, SequencePosition& consumed, SequencePosition& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.ParseRequest(ReadOnlySequence
1& buffer, SequencePosition& consumed, SequencePosition& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1Connection.TryParseRequest(ReadResult result, Boolean& endConnection) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequestsAsync[TContext](IHttpApplication
1 application) dbug: Microsoft.AspNetCore.Server.Kestrel[10] Connection id "0HM2QU64LCR9J" disconnecting. dbug: Microsoft.AspNetCore.Server.Kestrel[2] Connection id "0HM2QU64LCR9J" stopped. dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[6] Connection id "0HM2QU64LCR9J" received FIN. dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7] Connection id "0HM2QU64LCR9J" sending FIN because: "The Socket transport's send loop completed gracefully."
Added Http/2 support in Kestrel as suggested, but still got an error:
Grpc.Core.RpcException: 'Status(StatusCode="Unknown", Detail="Received http2 header with status: 307", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1600342649.633000000","description":"Received http2 :status header with non-200 OK status","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\http\client\http_client_filter.cc","file_line":130,"grpc_message":"Received http2 header with status: 307","grpc_status":2,"value":"307"}")'