umbraco / Umbraco.Cloud.Issues

Public issue tracker for Umbraco Cloud
26 stars 2 forks source link

Keep alive failed - System.Threading.Tasks.TaskCanceledException #466

Closed hfloyd closed 3 months ago

hfloyd commented 3 years ago

Issue description

I keep getting these errors on the live site error log. I used an UmbracoSettings.config transform to set the proper domain name, so the error is not a localhost 404 (a common issue I've seen elsewhere).

Message:
Keep alive failed (at '"https://PROJECT.euwest01.umbraco.io/api/keepalive/ping"').

Exception:
System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Umbraco.Web.Scheduling.KeepAlive.<PerformRunAsync>d__5.MoveNext()

Versions

Umbraco Id Umbraco 8.17.0 Deploy 4.3.0.0 Forms 8.8.0

hfloyd commented 3 years ago

A change to the way the transform rule was written, provided by Support seems to have resolved the issue.

<?xml version="1.0" encoding="utf-8" ?> 
<settings xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
    <keepAlive disableKeepAliveTask="false" keepAlivePingUrl="https://PROJECT ENV URL GOES HERE.euwest01.umbraco.io/api/keepalive/ping" xdt:Locator="Match(keepAlivePingUrl)" xdt:Transform="Replace"/> 
</settings>
hfloyd commented 3 years ago

Actually, the issue is back... and now using "localhost" url - so it seems the transform DOESN'T work.

Error in log:

Message:
Keep alive failed (at '"http://localhost/umbraco/api/keepalive/ping"').

Exception:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:80
   at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Umbraco.Web.Scheduling.KeepAlive.<PerformRunAsync>d__5.MoveNext()
hfloyd commented 3 years ago

On another Umbraco Cloud project (let's call it "H"), I saw 3000+ keepalive errors on the live site Error Log in the portal - all like this:

Message: Keep alive failed (at '"https://localhost/umbraco/api/keepalive/ping"').

Exception:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:443
   at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Umbraco.Web.Scheduling.KeepAlive.<PerformRunAsync>d__5.MoveNext()

I added some umbracoSettings.config.xdt files, set up as follows:

<?xml version="1.0" encoding="utf-8" ?>
<settings  xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <!--
  keepAlive
    @disableKeepAliveTask
      Disables the periodic KeepAliveTask when set to "true".
      Use this setting to disable the KeepAliveTask in case you already have an alternative.
      For example, Azure App Service has keep alive functionality built-in.
      Defaults to "false".
    @keepAlivePingUrl
      The url of the KeepAlivePing action. By default, the url will use the umbracoApplicationUrl setting as the basis.
      Change this setting to specify an alternative url to reach the KeepAlivePing action. eg http://localhost/umbraco/api/keepalive/ping
      Defaults to "{umbracoApplicationUrl}/api/keepalive/ping".
  -->
  <keepAlive disableKeepAliveTask="false" keepAlivePingUrl="https://SITEALIAS.euwest01.umbraco.io/api/keepalive/ping"
              xdt:Transform="Replace"/>
</settings>

And after several hours, I checked the Live Log and no longer saw those errors.

Project "H": Umbraco Id Umbraco 8.17.0 Deploy 4.3.0.0 Forms 8.7.6

sajumb commented 2 years ago

Thanks for the bug report. We have created a ticket in our backlog. We will consider it and try to reproduce the issue.

c9mb commented 2 years ago

Note - this solution does not work for v7 - as 'keepAlive' is apparently not a supported config settings element - so the site won't startup if you try to use this v8 solution, meaning that you can't configure the URL being requested for the keepAlive.

This might be resolvable on v7 using IIS Rewite if the requested URI for the task was something other than /umbraco - for more details see #533 - but at the moment I am logging a variety of HOST/URI combinations for the request, such as:

Failed (at "https://{custom-host}.:443/umbraco") -- note the invalid .: Failed (at "https://{project}.euwest01.umbraco.io:443/umbraco") Failed (at "https://{guid}.azurewebsites.net:443/umbraco")

CarlSargunar commented 2 years ago

I'm seeing a lot of these in my v8 cloud sites still - to confirm it's happening on Localhost URL for me

Keep alive failed (at '"https://localhost/umbraco/api/keepalive/ping"').

Exception : System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:443 at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult) at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar) --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Umbraco.Web.Scheduling.KeepAlive.d__5.MoveNext()

mclausen commented 3 months ago

Hi there 🤠

It seems like this is quite an old issue, and to me, it sounds looks like, and quacks like a CMS Issue 🦆 😅. Independent of the Umbraco Cloud, I assume that the symptoms would occur on any IIS-hosted processes, and ties into how Umbraco is resolving the address.

I am going to close this issue, and if this still is a problem please create an issue on the Umbraco CMS Tracker .

Kind regards @mclausen Cloud Platform/Core Teamlead