Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Frans Lammers 57 posts 400 karma points c-trib
    Nov 15, 2022 @ 10:07
    Frans Lammers
    0

    Cultiv.Hangfire does not work after upgrade Umbraco 9 to 10

    Hi,

    We are using the Cultiv.Hangfire Nuget package in one of our projects. After upgrading this project from Umbraco 9.5.4 to Umbraco 10.3.2 and upgrading the package to Cultiv.Hangfire 2.3.0 we have a problem with hangfire.

    When we run the project we get the following error:

    An error occurred while starting the application.
    InvalidOperationException: JobStorage.Current property value has not been initialized. You must set it before using Hangfire Client or Server API.
    Hangfire.JobStorage.get_Current()
    

    When we run the project with the task commented out, it runs but the Hangfire dashboard under Settings remains empty, showing only the loading-icon.

    Does anybody know what to do here?

    thanks,

    Frans

  • Huw Reddick 1737 posts 6098 karma points MVP c-trib
    Nov 15, 2022 @ 13:40
    Huw Reddick
    0

    How are you registering hangfire in your startup.cs?

  • Frans Lammers 57 posts 400 karma points c-trib
    Nov 15, 2022 @ 15:17
    Frans Lammers
    0

    We don't register it in startup.cs. In Umbraco 9 the package takes care of that, we only needed to add a composer, like:

     public class OurTasksComposer : IComposer
        {
            public void Compose(IUmbracoBuilder builder)
            {
                builder.Services.AddScoped<IOurTask, OurTask>();
                RecurringJob.AddOrUpdate<IOurTask>(x => x.DoOurTask(), Cron.Daily()); 
            }
        }
    

    Up until the upgrade to Umbraco 10 this worked.

  • Huw Reddick 1737 posts 6098 karma points MVP c-trib
    Nov 15, 2022 @ 17:03
    Huw Reddick
    0

    not sure I'm fraid, I don't register my jobs using a composer

  • Frans Lammers 57 posts 400 karma points c-trib
    Nov 16, 2022 @ 17:16
    Frans Lammers
    100

    I found the answer:

    First Umbraco 10 leaves the connection in appsettings.json empty which causes the JobStorage.Current error.

    Secondly Umbraco 10 uses SQLite as default on localhost, which is not supported by the Cultiv.Hangfire package. When I create a local SQL database and connect it using a connectionstring in appsettings.json everything works as expected.

  • Jay 413 posts 639 karma points
    Jan 31, 2024 @ 12:28
    Jay
    0

    Hi Frans,

    I'm having the same issue, do you use a separate DB for your hangfire for the connection string?

  • Frans Lammers 57 posts 400 karma points c-trib
    Jan 31, 2024 @ 13:53
    Frans Lammers
    0

    No, I use one connection string, so the Hangfire tables are written to the Umbraco DB. (Our project is hosted on Umbraco Cloud, so the connection string is only used locally.)

  • Huw Reddick 1737 posts 6098 karma points MVP c-trib
    Nov 16, 2022 @ 17:52
    Huw Reddick
    0

    Glad you got it sorted

  • Huw Reddick 1737 posts 6098 karma points MVP c-trib
    Nov 17, 2022 @ 08:24
    Huw Reddick
    0

    There is a SSQLite Storage plugin available for anyone using SQLite, I don't know if it works with Cultiv.Hangfire as I use the standard Hangfire.AspNetCore package in mine.

    https://github.com/raisedapp/Hangfire.Storage.SQLite

Please Sign in or register to post replies

Write your reply to:

Draft