Closed msh2050 closed 3 years ago
the issue in getting the value by IConfiguration interface from the "appsettings.json"
"DatabaseSettings": {
"ConnectionString": "mongodb://localhost:27017",
"DatabaseName": "CatalogDb",
"CollectionName": "Products"
},
if I add this code:
var clientTxt = configuration.GetValue<string>("DatabaseSettings:ConnectionString");
var databasTxt = configuration.GetValue<string>("DatabaseSettings:DatabaseName");
var producTxt = configuration.GetValue<string>("DatabaseSettings:CollectionName");
Console.Write($"client: {clientTxt} \ndatabase: {databasTxt} \nproduct {producTxt}");
I will get
client: mongodb://catalogdb:27017
database: ProductDb
product Products
sorry this is because it get the settings from appsettings.Development.json just corrected that and it is ok
clossing this
I get this error when I run Catalog.API solution
ducker installed and the container is working...
System.TimeoutException: 'A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "1", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/catalogdb:27017" }", EndPoint: "Unspecified/catalogdb:27017", ReasonChanged: "Heartbeat", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.Net.Sockets.SocketException (11001): No such host is known. at System.Net.NameResolutionPal.ProcessResult(SocketError errorCode, GetAddrInfoExContext* context) at System.Net.NameResolutionPal.GetAddressInfoExCallback(Int32 error, Int32 bytes, NativeOverlapped* overlapped) --- End of stack trace from previous location --- at MongoDB.Driver.Core.Connections.TcpStreamFactory.ResolveEndPointsAsync(EndPoint initial) at MongoDB.Driver.Core.Connections.TcpStreamFactory.CreateStreamAsync(EndPoint endPoint, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken) --- End of inner exception stack trace --- at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken) at MongoDB.Driver.Core.Servers.ServerMonitor.InitializeConnectionAsync(CancellationToken cancellationToken) at MongoDB.Driver.Core.Servers.ServerMonitor.HeartbeatAsync(CancellationToken cancellationToken)", LastHeartbeatTimestamp: "2021-06-23T18:18:01.2912448Z", LastUpdateTimestamp: "2021-06-23T18:18:01.2912453Z" }] }.'