c# - .Net 5 在 Ubuntu 中无法连接 mongodb
问题描述
我已经测试了 Windows 和 Mac 以连接到远程数据库。只有 Docker 中部署的 Ubuntu 无法连接我对网络层一无所知。帮助
这是地址 mongodb+srv://xxxx:xxxx@cluster0.xxxxx.mongodb.net/myFirstDatabase?retryWrites=true&w=majority"
这是日志
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", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/cluster0-shard-00-00.koby6.mongodb.net:27017" }", EndPoint: "Unspecified/cluster0-shard-00-00.koby6.mongodb.net:27017", ReasonChanged: "Heartbeat", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.
---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: PartialChain
at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception)
at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
at MongoDB.Driver.Core.Connections.SslStreamFactory.CreateStreamAsync(EndPoint endPoint, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
解决方案
最后我通过调用解决了我自己的问题
apt-get install -y wget
apt-get install -y apt-transport-https
错误不再发生
推荐阅读
- c++ - VC runtime 2017 中 scanf 函数族的位置,用于 MinGW 7
- css - Symfony 4 和 webpack 安可,在添加 CSS 第三个库时寻找好的做法
- python-3.x - 使用 pystone.py 测试 Windows 10 中的 python 与 WSL 中的 python
- json - 如何从 bson 文档呈现 json 字符串
- tkinter - Python3(Tkinter)突出显示焦点上的文本
- javascript - 将属性添加到其他文件中的原型函数
- java - 将 ImageView 准确地保存在 XML 位置
- openssl - x509 ocspid 选项生成的密钥哈希与证书的公钥之间的区别
- wpf - WPF Datagrid 在 MVVM 架构中获取单元格值
- php - 无法访问 xampp-vm 上的 laravel-websockets 仪表板