gpt4 book ai didi

c# - "Timeout while getting a connection from pool."Hangfire.Postgres

转载 作者:行者123 更新时间:2023-11-29 11:47:48 28 4
gpt4 key购买 nike

我是 Hangfire 的新手,所以我可能在某个地方搞砸了。我将 Hangfire 配置为:https://github.com/HangfireIO/Hangfire#installation

但不是:

 config.UseSqlServerStorage("<connection string or its name>");

我有:

 config.UsePostgreSqlStorage("Server=127.0.0.1;Port=5432;User Id=postgres;Password=pwd;Database=Hangfire");

所以我在我的数据库中创建了一个 Hangfire 数据库。

然后,我正在构建并运行我的项目。没关系。在我的 postgres 上创建 Hangfire DB 中的所有表。效果很好。

但是,当我尝试时:

   BackgroundJob.Enqueue(() => HubService.SendPushNotificationToUsers(threadParticipants,  messageApi.SenderId, messageApi.SenderName, messageApi.ThreadId, messageApi.Content));

我收到 InnerMessage 异常:

  "Timeout while getting a connection from pool." postgres

我错过了什么吗?

最佳答案

尝试通过 ConnectionString 或 String Builder 关闭连接池。

这是我们的做法

        var sb = new NpgsqlConnectionStringBuilder(connectionString);
sb.Pooling = false;
app.UseHangfire(config =>
{
config.UseActivator(new WindsorJobActivator(container.Kernel));
config.UsePostgreSqlStorage(sb.ToString(), new PostgreSqlStorageOptions() { UseNativeDatabaseTransactions = true });
config.UseServer();
});

关于c# - "Timeout while getting a connection from pool."Hangfire.Postgres,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28202608/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com