The "Send emails" scheduled task failed with the "One or more errors occurred.

3 weeks ago
Hi,
I have already read every post in the forum about this problem and nothing works...

Emails are not sent automatically every 60 seconds as defined in the system.
But when we click run now all emails are sent properly...so why does automatic sending not work?

Thanks for help.

The "Send emails" scheduled task failed with the "One or more errors occurred. (No connection could be made because the target machine actively refused it)" error (Task type: "Nop.Services.Messages.QueuedMessagesSendTask, Nop.Services". Store name: "Materials". Task run address: "https://materials.co.il/scheduletask/runtask").


System.AggregateException: One or more errors occurred. (No connection could be made because the target machine actively refused it) ---> System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Nop.Services.Tasks.TaskThread.Run() in C:\repos\NopCommerce\Materials\src\Libraries\Nop.Services\Tasks\TaskThread.cs:line 71
---> (Inner Exception #0) System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)<---
3 weeks ago
Check that you have the correct URL specified in admin area > configuration > stores.
If your site uses SSL, then be sure the prefix is https:
If you make a change to the URL, then restart your site.
3 weeks ago
We don't use SSL we use Coludflare, So we get SSL from Coludflare

I've already checked it out and restart my site...Nothing worked.
This is the web: https://materials.co.il/
3 weeks ago
Maybe it's related to Cloudflare; can you disable it, restart the site, and then test?
3 weeks ago
It's unrelated because the other sites in Cloudflare and everything works properly....
Only the version is different.
3 weeks ago
That doesn't mean it's not related.  Yes, the way the scheduler works now has changed; the way it now uses a different context/thread may not work nicely with your CloudFlare configuration.  It's worth testing to eliminate it.
3 weeks ago
"Actively refused it" means that the host sent a reset instead of an ack when you tried to connect. It is therefore not a problem in your code. Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that port. This may be because it is not running at all or because it is listening on a different port.

refer below url its might be help you.
http://csharp.net-informations.com/communications/connection.htm
https://our.umbraco.com/forum/umbraco-forms/88858-no-connection-could-be-made-because-the-target-machine-actively-refused-it-12700125
3 weeks ago
sangeetshah wrote:
.... This may be because it is not running at all or because it is listening on a different port....

He said " other sites in Cloudflare and everything works properly....Only the version is different."