【发布时间】:2019-03-10 17:28:33
【问题描述】:
我正在尝试使用 Hangfire.Mongo NuGet 包让 Hanfire 使用 MongoDB 存储。
我正在做Configure() 中必要的最低限度的工作:
app.UseHangfireServer();
这个在ConfigureServices():
services.AddHangfire(
config => config.UseMongoStorage("mongodb://myhost:27017"),
"MyDatabase");
我已经验证数据库存在并且上面的连接字符串是正确的。
我得到了这个例外:
无法清除资源“迁移”上的锁定。 System.TimeoutException: 选择服务器 30000 毫秒后发生超时
CompositeServerSelector{ 选择器 = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }。集群状态的客户端视图是 { ClusterId : "1", ConnectionMode : "Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified /myhost:27017" }",端点:“未指定/myhost:27017”,状态:“断开连接”,类型:“未知”,HeartbeatException:“MongoDB.Driver.MongoConnectionException:
打开与服务器的连接时发生异常。 ---> System.Net.Sockets.SocketException: 没有这样的主机是已知的 在 System.Net.Dns.HostResolutionEndHelper(IAsyncResult asyncResult) ... 在 Hangfire.Mongo.DistributedLock.MongoDistributedLock.Cleanup() [Hangfire.Mongo.DistributedLock.MongoDistributedLock]
粗体部分让我相信某些信息没有设置或丢失在某个地方,但我没有做任何不寻常的事情。我检查了防火墙问题并尝试了answer 中的许多想法来解决其他人的类似问题。
我也尝试将连接字符串更改为所有这些
- mongodb://myhost:27017/MyDatabase
- mongodb://myhost:27017/?connect=replicaSet
- mongodb://myhost:27017/MyDatabase/?connect=replicaSet
【问题讨论】:
标签: c# mongodb mongodb-.net-driver hangfire asp.net-core-2.2