Hello,
I’m running into a little problem using Hangfire with SQL Server 2012 database. I have hangfire hosted in a ASP.NET MVC 5 web application using the OWIN startup, which works fine. It seems that Hangfire is eating up all the connections available in it’s application pool and very quickly starts hitting a timeout error trying to get a new connection. I’ve gone over the source for hangfire and it appears that all SqlConnection objects are disposed of properly so I’m not sure where connections are being eaten up. I’m primarily using RecurringJobs.
Example code:
if (r.IsActive)
{
RecurringJob.AddOrUpdate("ReportEmail_" + r.id,
() =>
CreateAndEmailReportJob.Execute(reportId, r.id, documentName, jsonParams),
Cron.Daily(timeToExecute.Hour, timeToExecute.Minute));
}
else
{
RecurringJob.RemoveIfExists("ReportEmail_" + r.id);
}
What I’m doing here is adding or updating the job (r.id doesn’t change once a job is created. I store it elsewhere so users can change when these reports are emailed.) if it’s still active, or removing it if it’s not active. This is called every time settings for this report are changed.
When I run the stored procedure sp_who2 on SQL Server I see that hangfire opens about 100 active connections. These connections are polling the server very often, running a batch every 5 seconds or so.
Any insight will help. If I’m using hangfire in a way it wasn’t designed that could be it but I need some input to help track down what’s eating the connection.
Thanks