On Windows 10 Pro 21H2 with VS2022 17.1.2 and .NET 6, I am porting a simple C# gRPC client to C++, but the C++ client always fails to connect to the server despite my code seemingly doing the same, and I ran out of ideas why.
My gRPC server is using SSL with a LetsEncrypt generated certificate (through LettuceEncrypt), thus I use default SslCredentials.
In C# (with Grpc.Core), I use gRPC as follows:
// Channel and client creation
var channel = new Channel("my.domain.org:12345", new SslCredentials());
var client = new MyGrpc.MyGrpcClient(channel);
// Sample call
LoginUserReply reply = client.LoginUser(new LoginUserRequest()
{
Username = username
});
I converted this to C++ as follows, mostly based on examples given on the gRPC website:
// Channel and client creation
auto channelCreds = SslCredentials(SslCredentialsOptions());
auto channel = CreateChannel("my.domain.org:12345", channelCreds);
auto stub = MyGrpc::NewStub(channel);
// Sample call
ClientContext context;
LoginUserRequest request;
request.set_username(username);
LoginUserReply reply;
Status status = m_stub->LoginUser(&context, request, &reply);
However, with the code like this in C++, status always reports failure with UNAVAILABLE (14) "Empty update".
Why is that the case, and how can I fix this?
Investigation I did so far:
Using only
InsecureChannelCredentials()results in UNAVAILABLE (14) "failed to connect to all addresses".Running the server in plain-text, the call does work with OK (0) for testing purposes only (suggested by Lei Yang).
I set
GRPC_TRACE=allandGRPC_VERBOSITY=DEBUGenvironment variables, but saw no extra logging from the client.In the C# server, I set the Grpc logging level to Debug, and only noticed getting no "Reading message" log line as with working / unencrypted clients.