Scheduled Tasks not running

1 year ago
I stated that wrong.  Turned on asp logging in the web.config file.  Restarted the application and let the log run for a minute or so.  Did the same thing to the online test site.

After comparing logs from both sites there is one thing different between the 2.
On the live site which does not run scheduled tasks I find scheduled tasks listed at the beginning of startup:
info: System.Net.Http.HttpClient.default.LogicalHandler[100]
      Start processing HTTP request POST https://www.hrpracing.com/scheduletask/runtask
info: System.Net.Http.HttpClient.default.LogicalHandler[100]
      Start processing HTTP request POST https://www.hrpracing.com/scheduletask/runtask
info: System.Net.Http.HttpClient.default.LogicalHandler[100]
      Start processing HTTP request POST https://www.hrpracing.com/scheduletask/runtask
info: System.Net.Http.HttpClient.default.LogicalHandler[100]
      Start processing HTTP request POST https://www.hrpracing.com/scheduletask/runtask
info: System.Net.Http.HttpClient.default.LogicalHandler[100]
      Start processing HTTP request POST https://www.hrpracing.com/scheduletask/runtask
info: System.Net.Http.HttpClient.default.ClientHandler[100]
      Sending HTTP request POST https://www.hrpracing.com/scheduletask/runtask
info: System.Net.Http.HttpClient.default.ClientHandler[100]
      Sending HTTP request POST https://www.hrpracing.com/scheduletask/runtask
info: System.Net.Http.HttpClient.default.ClientHandler[100]
      Sending HTTP request POST https://www.hrpracing.com/scheduletask/runtask
info: System.Net.Http.HttpClient.default.ClientHandler[100]
      Sending HTTP request POST https://www.hrpracing.com/scheduletask/runtask
info: System.Net.Http.HttpClient.default.ClientHandler[100]
      Sending HTTP request POST https://www.hrpracing.com/scheduletask/runtask

On the online testing site I get the following:
info: System.Net.Http.HttpClient.default.LogicalHandler[100]
      Start processing HTTP request POST https://XXXXXXX.hrpracing.com/scheduletask/runtask
info: System.Net.Http.HttpClient.default.ClientHandler[100]
      Sending HTTP request POST https://XXXXXXX.hrpracing.com/scheduletask/runtask

So far have been unable to find a difference between the 2 sites.  When we swapped test for live, we copied the database to the test site and everything works.  

Thanks!
1 year ago
I should have stated that the live site continues to have a problem with scheduled task while the test site works.
1 year ago
Problem has been resolved, it was due to a forgotten Hosts file entry (from testing phase) that was over-riding the DNS mapping. When the website tried invoking a WebRequest to itself, the request was directed to the old (test phase) IP address, and therefore failing. This was particularly frustrating since all other sites on the same server were responding to Invoke-WebRequest just fine.
5 months ago
As you mentioned, in your case, it was a host entry over riding, but in my case I'm using cloudflare and I needed to set up a host entry for my domain to localhost.
Ill bet it will  solve the problem for a lot of people.

just an entry with :
127.0.0.1 yourdomain.com

I got this solution from Yidna's post  here:

https://www.nopcommerce.com/en/boards/topic/78057/all-scheduled-tasks-fail-when-running-automatically-but-not-manually

its a shame that old posts get locked. It leaves so leave so many unresolved issues out there
4 months ago
sangeetshah wrote:
Are you using cloudflare? I got the same issue. I have reconfigure cloudflare and my schedule task getting worked


We are using cloudflare and my schedule task isnt operating. We are blocking traffic from the countries where my server is located using WAF in cloudflare so I have probably blocked myself

Do you recall what rule you set up to make it work?
4 months ago
It was literally just this entry in the hosts file :

127.0.0.1 yourdomain.com

that resolved it.
4 months ago
127.0.0.1 is your loopback address assigned to localhost and in Host file ( local DNS) you should not assign your domain name to it ..
Dotnet application server ( Kestrel ) is assigned to this address on port 5000 . if you are running your site in Proxy .. Check your page header response in your browser developer under Network .. make sure the Server section has Kestrel ..if is anything else, that might be the source of the problem as application server is not responding correctly to request.