Reputation: 165
)
We are trying to develop a .net application in wpf with which is consuming grpc services which are deployed on AWS. The connection is done through GRPC.
Our code is as follows:
public static GrpcManagerFactory GetGrpcManagerFactory(ConnectionConfiguration configuration, string connectionString, DataAccess.Util.Enumerations.LogLevel clientLogLevel, bool errorMode)
{
Logger logger = new Logger(connectionString, clientLogLevel);
var caRootsPem = File.ReadAllText(Path.Combine(@"..", "cacert.pem"));
var caRootsKey = new KeyCertificatePair(caRootsPem, File.ReadAllText(Path.Combine(@"..", "AmazonRootCA1.key")));
ChannelCredentials channelCredentials = new SslCredentials(caRootsPem, caRootsKey, VerifyPeerContext);
var channel = new Channel(configuration.GrpcHost, configuration.GrpcPort, channelCredentials, new List<ChannelOption> { });
channel.ConnectAsync(DateTime.Now.AddSeconds(10).ToUniversalTime());
var provider = DataAccess.DataProvider.Grpc.GrpcFactory.GetGrpcFactory(channel, configuration, logger.LogManager.LogController);
var manFactory = new GrpcManagerFactory(provider, channel, connectionString, configuration.InterfaceRetries, clientLogLevel);
manFactory.ErrorMode = errorMode;
return manFactory;
}
When we try to either do a heartbeat or grpc request (.protos), we get either a DNS error, or that all connections fail....
Any idea?
This is our ConnectionConfiguration
public ConnectionConfiguration ConnectionConfiguration
{
#if DEBUG
get
{
return new ConnectionConfiguration
{
ClientId = _client != null ? _client.ClientId : 0,
InterfaceRetries = _clientPreferences != null ? (_clientPreferences.Depot != null ? _clientPreferences.Depot.InterfaceRetries : 1) : 1,
WenAccessTokenUrl = "token",
WenClientId = "..",
WenClientSecret = "..",
RealWebServices = true,
GrpcHost = "..",
GrpcPort = ..,
GrpcChannelCredentials = ChannelCredentials.Insecure
};
}
}
We tried to self signed our request but we get the same error.
ERROR:
DNS resolution failed for service: (AWS host)
Upvotes: 0
Views: 316
Reputation: 36
Finally we got it working.
.Net Framework version 4.6.2
In the following way
List<ChannelOption> channelOptions = new List<ChannelOption>()
{
new ChannelOption("grpc.ssl_target_name_override", "services.hosted.in.the.cloud.com"),
};
var channelCreds = new SslCredentials(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @".\xxxxxxxxxxxxx.pem"));
var channel = new Channel("services.hosted.in.the.cloud.com", 443, channelCreds, channelOptions);
and at the System Environment Variables..
GRPC_DNS_RESOLVER: native
with this settings it worked for us, connecting the grpc client to the services deployed on aws cloud
Upvotes: 2