如何增加Hangfire作业超时时间

问题描述 投票:0回答:1

我有一个运行hangfire 1.7.2的.net核心应用程序。

所以我有这份工作,它执行SQL存储过程,并且它的运行时间很长,可能需要30分钟。

这给我以下错误:超时时间已到。在操作完成之前超时或服务器没有响应。该语句已终止。

services.AddHangfire(configuration => 

configuration.UseSqlServerStorage(Configuration.GetConnectionString("HangfireConnection"), 
new SqlServerStorageOptions
    {
        SlidingInvisibilityTimeout = TimeSpan.FromMinutes(30),
        QueuePollInterval = TimeSpan.Zero,
        UsePageLocksOnDequeue = false,
        DisableGlobalLocks = false
    }));

请帮帮我。

c# sql-server .net-core hangfire hangfire-sql
1个回答
0
投票

CommandTimeout上的SqlServerStorageOptions属性应该是您要寻找的。

将其增加到30分钟以上,您的工作将停止超时。

(请参阅源https://github.com/HangfireIO/Hangfire/blob/cf7bb08d24ee4953926b7717461bf8a23d895eb4/src/Hangfire.SqlServer/SqlServerConnection.cs

© www.soinside.com 2019 - 2024. All rights reserved.