Я настроил свой API ядра .net, подключенный к БД Mongo. Я подключился к нему из ConnectionString что-то вроде «mongodb // user: password @ server ...». На данный момент в локальной связи все в порядке, я могу подключиться с MongoDB. Проблема в том, что когда я его публикую, потоки журнала сервера показывают мне что-то, связанное с прокси Kestrel, и не могут разрешить "mongodb: //". На самом деле строка mongodb выглядит как неизвестно.
Я настроил соединение в файле app.settings.json:
"ConnectionStrings": {
"db": "mongodb: // admin: blbablabla @ url: 27017 /? authSource = admin"
var uri = new MongoUr(_configuration.GetSection(CONNECTIONSTRINGS)[db];
_mongoDBClient = new MongoClient(uri);
Это ошибка:
2019-01-25 13:10:42.366 +00:00 [Error] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLK2OOVSKRD5", Request id "0HLK2OOVSKRD5:00000001": An unhandled exception was thrown by the application.
System.TimeoutException: A timeout occured 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", ConnectionMode : "
Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId:
"{ ClusterId : 1, EndPoint : "Unspecified/urlmachine:27017" }", EndPoint:
"Unspecified/urlmachine:27017", State: "Disconnected", Type: "Unknown",
HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception
occurred while opening a connection to the server. --->
System.Net.Sockets.SocketException: No such host is known
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
at System.Net.Dns.HostResolutionEndHelper(IAsyncResult asyncResult)
at System.Net.Dns.EndGetHostAddresses(IAsyncResult asyncResult)
at System.Net.Dns.<>c.<GetHostAddressesAsync>b__25_1(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---