.NET 4.7.2 - The response ended prematurely
Closed this issue · 1 comments
Martin-Thiele commented
The example snippet
var address = GrpcChannel.ForAddress("http://localhost:6334");
var client = new QdrantGrpcClient(address);
// check qdrant is healthy
var healthResponse = client.Qdrant.HealthCheck(new HealthCheckRequest());
fails in .NET 4.7.2 with the following exception tree
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.") -> An error occurred while sending the request. -> The response ended prematurely.
it works fine on .NET 6
russcam commented
.NET Framework has limited supported for gRPC over HTTP/2, but it can be enabled by
- Configuring qdrant to use TLS, and you must use HTTPS, so you may want to set up cert validation
- Referencing Grpc.Net.Client.Web and configuring
GrpcWebHandler
as theHttpHandler
- Referencing System.Net.Http.WinHttpHandler 6.0.1 or later, and configuring
WinHttpHandler
as the inner handler forGrpcWebHandler
See Configure gRPC-Web with the .NET gRPC client and Use gRPC client with .NET Standard 2.0 for further details.
The following works:
var channel = GrpcChannel.ForAddress("https://localhost:51379", new GrpcChannelOptions
{
HttpHandler = new GrpcWebHandler(new WinHttpHandler
{
ServerCertificateValidationCallback =
CertificateValidation.Thumbprint("28fb5a5ef762238ec259ae46720180b855be3274ff39a9edc1b465a5b46a4546")
})
});
var callInvoker = channel.Intercept(metadata =>
{
metadata.Add("api-key", "password!");
return metadata;
});
var client = new QdrantGrpcClient(callInvoker);
// check qdrant is healthy
var healthResponse = client.Qdrant.HealthCheck(new HealthCheckRequest());
I'll add this to the docs.
A JSON based HTTP client is also in the works.