Background jobs getting cancelled after 30 minutes


#1

I’m using Hangfire to manage some long-running jobs within a .Net Web App but they keep getting cancelled after 30 minutes or so. I’ve set the code up to use cancellation tokens so that users can cancel the jobs gracefully if needed.

Elmah logs an exception as follows

Hangfire.Server.JobAbortedException: The operation was canceled.
at Hangfire.Server.ServerJobCancellationToken.ThrowIfCancellationRequested()

Is this an IIS setting I need to alter somewhere? It’s a little suspicious that 30 minutes comes round and the cancellation is thrown.

Thanks


#2

Hi, we’re using Hangfire Pro 2.1.0 with SqlServerStorage provided by 1.6.17 and are hitting a similar issue.

I have a background job that could take between 2 minutes and 24 hours to complete, but without fail the job is shown as being possibly aborted, then re-queued after 30 minutes. The server processing the job has vanished from the dashboard, BUT based on database updates still appears to be running for an indeterminate time once aborted.

Invisibility timeout is deprecated and should no longer be an issue. Any pointers would be gratefully received.


#3

As a quick update - we traced this behaviour to code within the task - in the case of a network disconnection that wasn’t handled gracefully, the exception bubbled up and killed the running task, re-queuing it as hf does for failed jobs. Once the exception was handled gracefully the task ran to completion consistently.