I have a gRPC service (written in .net core 3.1) deployed in windows server as a self hosted service running in kerstel.
I added the below configuration to get the service running in https.
"Kestrel": {
"EndpointDefaults": {
"Protocols": "Http2"
},
"Endpoints": {
"HttpsInlineCertFile": {
"Url": "https://hostname:8081",
"Protocols": "Http2",
"Certificate": {
"Path": "path to .pfx file",
"Password": "Super secret password"
}
}
}
Using the below code
using GrpcChannel channel = GrpcChannel.ForAddress(httpsHost);
var client = new MyClient(channel);
var response = client.GetEntity(RequestCreator.GetRequest());
Console.WriteLine("Recieved: " + response.ToString());
I get the an below exception and the inner exception is null.
Status(StatusCode=Internal, Detail="Error starting gRPC call: The SSL connection could not be established, see inner exception.")
Is there anything I should be adding to get the client to get the data from the service?
Thanks in advance
Sorry for the late response to my question. The problem was the proxy. What I ended up doing is create a webproxy, add the gRPC service URL to the bypassArrayList, create httpClientHandler, assigned the created proxy then create a httpClient that uses that httpClientHandler.
var proxy = new WebProxy
{
Address = new Uri(proxyServer),
UseDefaultCredentials = true,
BypassProxyOnLocal = true,
Credentials = CredentialCache.DefaultNetworkCredentials
};
proxy.BypassArrayList.Add(serviceUrl);
var httpClientHandler = new HttpClientHandler
{
Proxy = proxy,
DefaultProxyCredentials = CredentialCache.DefaultNetworkCredentials,
UseDefaultCredentials = true,
UseProxy = true,
};
var client = new HttpClient(httpClientHandler)
{
DefaultRequestVersion = HttpVersion.Version20
};
using var channel = GrpcChannel.ForAddress(serviceUrl, new GrpcChannelOptions
{
HttpClient = client
});