Grpc Error

Moved from GitHub dgraph.net/10

Posted by wolfheimrick:

I’m trying to follow the readme and I’m getting a Grpc error.

instead of

var client = new DgraphClient(new Channel("127.0.0.1:9080", ChannelCredentials.Insecure));

I’m writing

var channel = GrpcChannel.ForAddress("http://127.0.0.1:9080");
var client = new DgraphClient(channel);

Then I’m trying to alter the database without success. Is there a special grpc lib I should use?

ahaidar-oc commented :

@wolfheimrick I had the same issue in dotnet core. I have it now fixed by adding the following:
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

wolfheimrick commented :

Oh thanks, but I still get the same error. Neither the query nor the mutation succeed.

The error I get:

ExceptionalError with Message='Status(StatusCode=Internal, Detail="Error starting gRPC call: An error occurred while sending the request.")', Exception='Grpc.Core.RpcException: Status(StatusCode=Internal, Detail="Error starting gRPC call: An error occurred while sending the request.")
   at Dgraph.Transactions.ReadOnlyTransaction.<>c__DisplayClass11_0.<<QueryWithVars>b__0>d.MoveNext()        
--- End of stack trace from previous location where exception was thrown ---
   at Dgraph.DgraphClient.DgraphExecute[T](Func`2 execute, Func`2 onFail)'

Aaronmsv commented :

@wolfheimrick I’m getting the same errors and haven’t found a solution yet. However, you probably still need to set the ChannelCredentials to insecure. I’ve made a pull request #11 to update the README.

Aaronmsv commented :

I managed to fix the error. As @ahaidar-oc mentioned, you need AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); More information can be found here: Troubleshoot gRPC on .NET Core | Microsoft Docs

Also, make sure that you are connection to the right port or you’ll get that error while sending the request. The default port is 9080. I was an idiot and was using 8080.

The ChannelCredentials setting doesn’t need to be set anymore it seems. It works just fine without it.

wolfheimrick commented :

I’m gonna check that again then. Thanks

Even after setting the SetSwitch, the response is getting downgraded to Http/1.1:

Status(StatusCode=“Internal”, Detail=“Bad gRPC response. Response protocol downgraded to HTTP/1.1.”)

Well, I wrote this issue last june. The dgraph.net examples on the repo doesn’t work properly.
I switched to this client MichaelJCompton/Dgraph-dotnet.

Now it works.

The doc should link the MichaelJCompton’s repo instead of this one: dgraph-io/Dgraph-dotnet.

1 Like

Having the same issue as described in this thread. No idea how to solve it.
Try all different variations of set switch and credential Insecure.
Did a connectivity test with BloomRPC GRPC Client using check version method, which worked just fine. So no firewall, port or whatsoever issue
Try version 20.X and 21.X, both wouldn’t work and always return following error

Status(StatusCode=Internal, Detail=“Error starting gRPC call: An error occurred while sending the request.”)

My Code is running on latest .NET 5, Dgraph Version is 20.11

Thanks in advance for any suggestions.

=======================

Several hours later I found that the GRPC client used by the package is outdate hence I wouldn’t connect. Update the grpc net client to 2.38 and it suddenly started connecting.

Not sure if anyone actually checks these threads but .NET 5 requires gRPC client > 2.32 as described here: https://docs.microsoft.com/en-us/aspnet/core/grpc/troubleshoot?view=aspnetcore-5.0#call-insecure-grpc-services-with-net-core-client