Hangfire fetching database every 15 second

I use Recurring Job to call my function Test() with Cron.Daily() .
I does not need to fetch database every 15 second , my function executed every day only once .

how to stop hangfire to fetch database every 15 second ? or update interval.

this is configuration I am using it.
services.AddHangfire(config =>
config.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseDefaultTypeSerializer()
.UseSqlServerStorage(configuration.GetConnectionString(“BackOffice”))
);
var sqlStorage = new SqlServerStorage(configuration.GetConnectionString(“BackOffice”));
JobStorage.Current = sqlStorage;

services.AddHangfireServer(sqlStorage);
GlobalConfiguration.Configuration.UseSqlServerStorage(configuration.GetConnectionString(“BackOffice”));
services.AddHttpClient();

if you know please help me, thanks

this is done with the command where you start the job … you can edit when and how often with a cron-command (time)… so, post the row where you start the function so that we can see how you are starting the recurrent job.

Hi @Pelle :
even if I don’t use any recurring job now . it make check to server every 15 second .
I don’t need it to check database .

thank you.

ah, so you mean that there is a poll every 15 second and you do not want it ?

See if this works…

var options = new SqlServerStorageOptions
{
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero
};

GlobalConfiguration.Configuration.UseSqlServerStorage("", options);

Hi @Pelle
I try sqlServerStorageOption and don’t work also.

15s is the default polling interval for SqlServer. If the polling interval isn’t changing when you use SqlServerStorageOptions you’re probably setting it too late. You need to set it in the call to AddHangfire(), not later.

services.AddHangfire(config =>
    config
     .SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
     .UseSimpleAssemblyNameTypeSerializer()
     .UseDefaultTypeSerializer()
     .UseSqlServerStorage(configuration.GetConnectionString(“BackOffice”), 
           // Only poll for hangfire jobs once per hour
           new SqlServerStorageOptions{ 
                         QueuePollInterval = new TimeSpan(0, 1, 0, 0, 0))
           })
      
);

// These lines you had aren't needed: 
// var sqlStorage = new SqlServerStorage(configuration.GetConnectionString(“BackOffice”));
// JobStorage.Current = sqlStorage;

// You don't need to pass sqlServerStorage here; you've already set it in AddHangfire()
services.AddHangfireServer();

// This line is also not needed:  
// GlobalConfiguration .Configuration.UseSqlServerStorage(...

services.AddHttpClient();