Hangfire.PostgreSql: recurring job connection error after few hours of work

I’m using
Hangfire with PostgreSql.

I’m working with Hangfire version 1.5.4 and Hangfire.PostgreSql.dll 1.4.0.I’m using a recurring job that starts every minute.The recurring job under some condition insert new job in Hangfire (this queuing occurs about every 5 minutes).After few hours of work an error occurs.After error, recurring job continues to operate but the insertion of new the job always fails.Any Ideas? Error:

Hangfire.BackgroundJobClientException:
Background job creation failed. See inner exception for details. —>
Hangfire.BackgroundJobClientException: Background job creation failed. See
inner exception for details. —> Hangfire.BackgroundJobClientException:
Background job creation failed. See inner exception for details. —>
Hangfire.BackgroundJobClientException: Background job creation failed. See inner
exception for details. —> Hangfire.BackgroundJobClientException:
Background job creation failed. See inner exception for details. —>
System.ObjectDisposedException: Cannot access a disposed object.

Object name:
‘NpgsqlConnection’.

at Npgsql.NpgsqlConnection.CheckNotDisposed()

at Npgsql.NpgsqlConnection.CreateCommand()

at Npgsql.NpgsqlConnection.CreateDbCommand()

at System.Data.Common.DbConnection.System.Data.IDbConnection.CreateCommand()

at Dapper.CommandDefinition.SetupCommand(IDbConnection cnn, Action`2 paramReader)

at Dapper.SqlMapper.d__61`1.MoveNext()

at System.Collections.Generic.List1..ctor(IEnumerable1 collection)

at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable1 commandTimeout, Nullable1 commandType)

at Hangfire.PostgreSql.PostgreSqlConnection.CreateExpiredJob(Job job, IDictionary`2 parameters, DateTime createdAt, TimeSpan expireIn)

at Hangfire.Client.CoreBackgroundJobFactory.Create(CreateContext context)

at Hangfire.Client.BackgroundJobFactory.<>c__DisplayClass3.b__0()

at Hangfire.Client.BackgroundJobFactory.InvokeClientFilter(IClientFilter filter, CreatingContext preContext, Func`1 continuation)

at Hangfire.Client.BackgroundJobFactory.<>c__DisplayClass3.<>c__DisplayClass5.b__2()

at Hangfire.Client.BackgroundJobFactory.InvokeClientFilter(IClientFilter filter, CreatingContext preContext, Func`1 continuation)

at Hangfire.Client.BackgroundJobFactory.<>c__DisplayClass3.<>c__DisplayClass5.b__2()

at Hangfire.Client.BackgroundJobFactory.CreateWithFilters(CreateContext context, IEnumerable`1 filters)

at Hangfire.Client.BackgroundJobFactory.Create(CreateContext context)

at Hangfire.BackgroundJobClient.Create(Job job, IState state)

— End of inner exception stack trace —

at Hangfire.BackgroundJobClient.Create(Job job, IState state)

at Hangfire.BackgroundJobClientExtensions.Create[T](IBackgroundJobClient client, Expression`1 methodCall, IState state)

at BN.Framework.Servizi.Serv_Hangfire.Support.BNHangfireHelper.Enqueue[T](Int32 domainId, Int32 dbIdJobInfo, Int32 dbIdJobInfoD, String pQueueName, DbConnection hangfireDbConn) in c:\Bluenext001\Framework\Servizi\Serv_Hangfire\Support\BNHangfireHelper.cs:line 209

— End of inner exception stack trace —

at BN.Framework.Servizi.Serv_Error.BNCatchErrorService.Catch(Exception e)

at BN.Framework.Servizi.Serv_Hangfire.Support.BNHangfireHelper.Enqueue[T](Int32 domainId, Int32 dbIdJobInfo, Int32 dbIdJobInfoD, String pQueueName, DbConnection hangfireDbConn) in c:\Bluenext001\Framework\Servizi\Serv_Hangfire\Support\BNHangfireHelper.cs:line 220

at BN.Framework.Servizi.Serv_Hangfire.Support.BNHangfireHelper.AddJobInHangfire[T](DbConnection hangFireDBConnection, String inputData, String className, String jobType, Boolean useOutputDependence, Int32 domainId, String recurringRule, String jobDescription) in c:\Bluenext001\Framework\Servizi\Serv_Hangfire\Support\BNHangfireHelper.cs:line 1344

— End of inner exception stack trace —

at BN.Framework.Servizi.Serv_Error.BNCatchErrorService.Catch(Exception e)

at BN.Framework.Servizi.Serv_Hangfire.Support.BNHangfireHelper.AddJobInHangfire[T](DbConnection hangFireDBConnection, String inputData, String className, String jobType, Boolean useOutputDependence, Int32 domainId, String recurringRule, String jobDescription) in c:\Bluenext001\Framework\Servizi\Serv_Hangfire\Support\BNHangfireHelper.cs:line 1352

at BN.Framework.Servizi.Serv_Hangfire.BNHangfireJobRecurring.enqueueJobIfMatchRule(Int32 domainId, String sqlCondition, RERule reRule, String workerId) in c:\Bluenext001\Framework\Servizi\Serv_Hangfire\BNHangfireJobRecurring.cs:line 306

— End of inner exception stack trace —

at BN.Framework.Servizi.Serv_Error.BNCatchErrorService.Catch(Exception e)

at BN.Framework.Servizi.Serv_Hangfire.BNHangfireJobRecurring.enqueueJobIfMatchRule(Int32 domainId, String sqlCondition, RERule reRule, String workerId) in c:\Bluenext001\Framework\Servizi\Serv_Hangfire\BNHangfireJobRecurring.cs:line 313

at BN.Framework.Servizi.Serv_Hangfire.BNHangfireJobRecurring.Execute() in c:\Bluenext001\Framework\Servizi\Serv_Hangfire\BNHangfireJobRecurring.cs:line 120

— End of inner exception stack trace —

at BN.Framework.Servizi.Serv_Error.BNCatchErrorService.Catch(Exception e)

at BN.Framework.Servizi.Serv_Hangfire.BNHangfireJobRecurring.Execute() in c:\Bluenext001\Framework\Servizi\Serv_Hangfire\BNHangfireJobRecurring.cs:line 133