Scheduled Tasks not running

1 year ago
Scheduled tasks and store url seem to be fine and I am able to run manually with the exception of keep alive which fails with 404 error.  At times the scheduled tasks will run on schedule for anywhere from 5 minutes to 8 hours and will then stop.  Nothing is logged in the system log.  They sometimes will run when I reload the application, but mostly not.  No reasoning that I have been able to tell.  

Version is 4.50.4 with a few modifications to the source code.

Any one else experience this and find a solution?

Thanks for reading and all suggestions are appreciated.

Vic Lepouce
1 year ago
HI
Please check your store URL and Host URL
due to that it can raise scheduled not working

however please post error list or detail from the log so can get more idea for that

Thanks
1 year ago
The 404 error seems odd, so maybe it's related...
Try hitting your site with the URL that the keepalive uses:
yoursite.com/keepalive/index

The returned page will be blank, but it should not return 'page not found'
1 year ago
ilyas_patel,
The HTTP_HOST is www.hrpracing.com and the HOST values is www.hrpracing.com/

The Store URL is https://www.hrpracing.com/.  

Unfortunately there is no log being produced, only the 404 error when I set Keep Alive active.

New York,
When I go to /keepalive/index page, I do get a blank page, not the 404.  IT fails when I try to run manually from the scheduled task page or try to run it scheduled.  Non of the other scheduled tasks run reliably, running for a short time and then not restarting for hours or days.  It will suddenly restart the scheduled tasks and work for a little while.

The only thing in the log relates to the keep alive:
Log level
Error
Short message
The "Keep alive" scheduled task failed with the "One or more errors occurred. (Response status code does not indicate success: 404 (Not Found).)" error (Task type: "Nop.Services.Common.KeepAliveTask". Store name: "Hepfner Racing Products". Task run address: "https://www.hrpracing.com/scheduletask/runtask").
Full message
System.AggregateException: One or more errors occurred. (Response status code does not indicate success: 404 (Not Found).)
---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
   at Nop.Services.Common.StoreHttpClient.KeepAliveAsync() in D:\DEV-Nop\NOP-4-50-4\nopCommerce_4.50.4_Source Mod Traction\Libraries\Nop.Services\Common\StoreHttpClient.cs:line 43
   at Nop.Services.Common.KeepAliveTask.ExecuteAsync() in D:\DEV-Nop\NOP-4-50-4\nopCommerce_4.50.4_Source Mod Traction\Libraries\Nop.Services\Common\KeepAliveTask.cs:line 32
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at Nop.Services.ScheduleTasks.ScheduleTaskRunner.ExecuteTask(ScheduleTask scheduleTask) in D:\DEV-Nop\NOP-4-50-4\nopCommerce_4.50.4_Source Mod Traction\Libraries\Nop.Services\ScheduleTasks\ScheduleTaskRunner.cs:line 79
   at Nop.Services.ScheduleTasks.ScheduleTaskRunner.<>c__DisplayClass8_0.<ExecuteAsync>b__0() in D:\DEV-Nop\NOP-4-50-4\nopCommerce_4.50.4_Source Mod Traction\Libraries\Nop.Services\ScheduleTasks\ScheduleTaskRunner.cs:line 146
   at Nop.Core.Caching.MemoryCacheManager.PerformActionWithLock(String key, TimeSpan expirationTime, Action action) in D:\DEV-Nop\NOP-4-50-4\nopCommerce_4.50.4_Source Mod Traction\Libraries\Nop.Core\Caching\MemoryCacheManager.cs:line 214
   at Nop.Services.ScheduleTasks.ScheduleTaskRunner.ExecuteAsync(ScheduleTask scheduleTask, Boolean forceRun, Boolean throwException, Boolean ensureRunOncePerPeriod) in D:\DEV-Nop\NOP-4-50-4\nopCommerce_4.50.4_Source Mod Traction\Libraries\Nop.Services\ScheduleTasks\ScheduleTaskRunner.cs:line 146
IP address
98.144.150.213
Customer
Page URL
https://www.hrpracing.com/Admin/ScheduleTask/RunNow/2
Referrer URL
https://www.hrpracing.com/Admin/ScheduleTask/List
Created on
3/1/2023 8:06:56 PM
1 year ago
vlepouce wrote:
The HTTP_HOST is www.hrpracing.com and the HOST values is www.hrpracing.com/


Do you have a / at the end of the Host values - If so remove the / and see if that makes a differnce
1 year ago
Yidna wrote:
The HTTP_HOST is www.hrpracing.com and the HOST values is www.hrpracing.com/


Do you have a / at the end of the Host values - If so remove the / and see if that makes a differnce


I have tried that with no success.  

We have a test site and a live site.  On the test site the scheduled tasks runs while on the live site it does not.   We swapped the test and live (repointed and save live db to test db) and the problem stays with the live site.  Not sure what I am missing.
1 year ago
Are you using cloudflare? I got the same issue. I have reconfigure cloudflare and my schedule task getting worked
1 year ago
sangeetshah wrote:
Are you using cloudflare? I got the same issue. I have reconfigure cloudflare and my schedule task getting worked


No, on a local web host.

Had them swap the 2 sites around thinking the problem would follow the site, unfortunately it stayed with the live setup.
1 year ago
Turning on asp filter gave me a couple of failures,
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[3]
      Authorization failed for the request at filter 'Nop.Web.Framework.Mvc.Filters.HttpsRequirementAttribute+HttpsRequirementFilter'.

This comes up twice after a restart.  Not sure if this has anything to do with the issue of scheduled tasks not running.  Nothing appears in the NopCommerce log and event log for IIS.  



Thanks!
1 year ago
Please clarify what you did to "Turning on asp filter".
If you are using SSL locally, then the error could be related to SSL Cert.