Open Closed

Hangfire error when upgrading ABP to v8.2.0 #7433


User avatar
0
thanhlg created

Hi ABP Team,

After upgrading to version 8.2.0, I encountered an error as shown in the image. When using version 8.1.3, Hangfire works fine without that error. Could you please help me check it?

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

6 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    This is because the period is too long.

    You can check this logic https://github.com/abpframework/abp/blob/OrganizationUnitEto/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs#L80-L101

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    thanhlg created

    In my previous code, I used Cron.Daily(8, 0) because I wanted to perform a task every day at 8 AM. After reviewing the file you sent me, I tried using CronExpression = $"*/50 * * * * *"; but the error still persists. Could you please let me know where I went wrong? And why does it work in version 8.1.3 but not in version 8.2.0?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    i will check it

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    You can try this, i will fix it in the next patch version.

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(IBackgroundWorkerManager), typeof(HangfireBackgroundWorkerManager))]
    public class MyHangfireBackgroundWorkerManager: HangfireBackgroundWorkerManager
    {
        public MyHangfireBackgroundWorkerManager(IServiceProvider serviceProvider) : base(serviceProvider)
        {
        }
    
    
        protected override string GetCron(int period)
        {
            var time = TimeSpan.FromMilliseconds(period);
            string cron;
    
            if (time.TotalSeconds <= 59)
            {
                cron = $"*/{time.TotalSeconds} * * * * *";
            }
            else if (time.TotalMinutes <= 59)
            {
                cron = $"*/{time.TotalMinutes} * * * *";
            }
            else if (time.TotalHours <= 23)
            {
                cron = $"0 */{time.TotalHours} * * *";
            }
            else if(time.TotalDays >= 1)
            {
                cron = $"0 0 0 1/{time.TotalDays} * *";
            }
            else
            {
                throw new AbpException(
                    $"Cannot convert period: {period} to cron expression, use HangfireBackgroundWorkerBase to define worker");
            }
    
            return cron;
        }
    }
    
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    thanhlg created

    Hi liangshiwei,

    The previous error is fixed, but now there's this new error. It only occurs in version 8.2.0, not in version 8.1.3

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    could you create a new ticket, thanks

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.