I just want Connect and send string to Grpc server and get string.
The server is written by python, And I make client by C#
It works in python client
This is my client Code and Exception log.
Client Code
static async Task Main(string[] args)
{
using var channel = GrpcChannel.ForAddress("http://1.2.3.4:5555");
var client = new GRPCSerivce.GRPCSerivceClient(channel);
var reply = await client.SynAck_ResultStringAsync(new DataRequest { Keys = "12345" });
Console.WriteLine($"Return: {reply.Datas}");
Console.WriteLine("Press any key to exit");
Console.ReadLine();
}
The error occured in this line
var reply = await client.SynAck_ResultStringAsync(new DataRequest { Keys = "12345" });
and this is exception code
Grpc.Core.RpcException: 'Status(StatusCode="Unavailable", Detail="Error starting gRPC call. HttpRequestException: An error occurred while sending the request. IOException: The response ended prematurely.", DebugException="System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: The response ended prematurely.
at System.Net.Http.HttpConnection.FillAsync()
at System.Net.Http.HttpConnection.ReadNextResponseHeaderLineAsync(Boolean foldedHeadersAllowed)
at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)")'
The server has already explicitly declared the port number.
What makes this exception?