russcam/qdrant-dotnet-client

.NET 4.7.2 - The response ended prematurely

Closed this issue · 1 comments

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

.NET Framework has limited supported for gRPC over HTTP/2, but it can be enabled by

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.