Keep Alive Scheduled task not executing

9 месяцев назад
Hi,

So this is a more of general problem, we have 10 or so nopCommerce sites both on our developer and production machines and all sites are experiencing the same problem.
None of the scheduled tasks are running unless I go to the web site via my browser which "wakes it up". Once a site goes into hibernation the tasks stop executing again.

So, to stop the sites from hibernating the keep alive task seems essential, right? Fine, I have configured the sites to run the keep alive task every 300 seconds but the site still goes down and I will have to wake it up with my browser again, the keep-alive task and all other tasks are then run if the conditions are met.

So the solution for this must be to get the keep-alive task running as it should, correct?
I can click the keep-alive task from the admin page and it executes fine, I can also visit the keep-alive url and it is found. The task also executes automatically when I wake the site up via my browser so everything seems to be working as it should apart from the fact that when I leave the site the scheduled task never executes again.

This is really only a problem on our development machines, the production sites are visited all the time so the tasks will always execute.

The reason that this has come up is that I have recently built a plugin that fetches messages from a service bus in Azure, and I want these to be processed on our dev sites that might not be visited for weeks via an ordinary browser.

So, do you have any idea why the task is not executing? We're running version 4.2 on all sites.

Best regards,
Peter
9 месяцев назад
Hi Peter,

1. Do you have a valid URL specified in admin area > configuration > stores?
2. Do you see any errors in the log?
3. Ensure that valid firewall limitations/rules are configured. For example, Cloudflare can block such requests in some cases
9 месяцев назад
Hi Andrei!

Thanks for your reply and I hope you are doing well!

Well, after debugging some, it turns out that the Index method is not called in the KeepAliveController. When the scheduled task executes, the httpclient just returns an empty string and no error, even though it never reaches the index controller method.
Calling the Index method from my browser does not work either.

It seems to be the KeepAliveMiddleware that prevents the method from being called, If I skip the middleware the task reaches the controller method.
I dont want to remove it because it's obviously there for a reason as it states in a comment: "We ignore (the keep alive url) it to prevent creating a guest customer records".

The same thing is stated in a comment in the KeepAliveController, so I don't know which one tells the truth, or maybe both. :)

Seems like I'm stuck, but I'll investigate further.

Looking forward to the next nopCommerce Days :)

Best regards,
Peter
9 месяцев назад
Be sure to check this, because it's a common issue for the keep alive:
"1. Do you have a valid URL specified in admin area > configuration > stores?"

Be sure to have trailing "/" - e.g.
  http://yourstore.com/
or if SSL
  https://yourstore.com/
9 месяцев назад
Yes, I actually forgot to respond to Andreis questions, but this is how our sites are set up.

1. Yes the URL is correct with https:// and we have valid certificates.
2. No errors in the log, when the task runs, it's always a successful (when the site is active)
3. Web ports are open, no other specific firewall rules. Again, tasks still the tasks run when site is active.

Haven't had the time to look at the KeepAliveMiddleware issue yet, but might disable it and see if it runs correctly.

Best regards,
Peter