I'm new to Hangfire, so probably I'm messing up somewhere. I have the Hangfire configured like in: https://github.com/HangfireIO/Hangfire#installation
but instead of:
config.UseSqlServerStorage("<connection string or its name>");
I have:
config.UsePostgreSqlStorage("Server=127.0.0.1;Port=5432;User Id=postgres;Password=pwd;Database=Hangfire");
So I created an Hangfire Database in my DB.
And then, I'm building and running my project. It is ok. Creating all tables in Hangfire DB at my postgres. It is working great.
But then, when I'm trying:
BackgroundJob.Enqueue(() => HubService.SendPushNotificationToUsers(threadParticipants, messageApi.SenderId, messageApi.SenderName, messageApi.ThreadId, messageApi.Content));
I'm receiving an exception with the InnerMessage:
"Timeout while getting a connection from pool." postgres
Am I missing something?
Try to turn off Connection Pool via ConnectionString or String Builder.
Here is how we do it
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();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With