Hello,
I'm getting this issue too frequent on my Umbraco logs but I cannot find the real issue.
This error repeats every 5 min (as you can see on the code).
I'm working with Umbraco 7.6.3 hosted on a scaled out Azure Web App.
I have custom UrlRewrites on my web.config
Can this rewrites screw the schedule publish of umbraco? This are the errors:
2018-06-09 14:36:22,195 [P4232/D2/T108] ERROR Umbraco.Web.Scheduling.KeepAlive - Failed (at "https://localhost/umbraco").
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.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.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Umbraco.Web.Scheduling.KeepAlive.<PerformRunAsync>d__4.MoveNext()
2018-06-09 14:41:22,211 [P4232/D2/T40] ERROR Umbraco.Web.Scheduling.KeepAlive - Failed (at "https://localhost/umbraco").
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.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.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Umbraco.Web.Scheduling.KeepAlive.<PerformRunAsync>d__4.MoveNext()
Yes this can be an issue. Umbraco works be determining the connection it can use to communicate server side. Looking at your error message the URL it's trying to connect to is https://localhost/umbraco which is suspect you can't connect to from the server.
Can you check if umbracoUseSSL is set to true in the web.config as this may help. If you still have trouble after this you can hardcode the server side URL by setting umbracoApplicationUrl="http://localhost/umbraco" in config/umbracoSettings.config.
Hello Andy,
Thank you for your answer. I have umbracoUseSSL on true at the moment I post the issue. I will try with the umbracoApplicationUrl="https://localhost/umbraco" but I have a question here: Do I need to use http or https on the url?
I get the same error, but the proposed solution by setting umbracoApplicationUrl="http://localhost/umbraco" in config/umbracoSettings.config doesn't work for me. The error still appears every 2 minutes.
We are working with Umbraco 7.5.4 assembly: 1.0.6136.27241
On our Umbraco 8 site, I've tried the above (changing the web.routing line in umbracoSettings so that the umbracoApplicationUrl="https://ourwebsitename/umbraco"), but still getting the keepalive errors every 5 minutes. I also read it could be a TLS thing but we have TLS 1.0 and 1.1 turned off on our Windows 10 server. I've read about adding this line somewhere, not sure where it goes: System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12
You have to make a composition something like below:
public class MyComponent : IComponent
{
public void Initialize()
{
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
}
}
I have umbraco version 7.14.0 and have a same problem with a subdomain
2020-02-13 00:08:42,607 [P9100/D2/T23] ERROR Umbraco.Web.Scheduling.KeepAlive - Failed (at "http://subdomain.domain.com/umbraco").
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host.
This is due to the server running the Umbraco-site requiring TLS 1.2 connections (Azure App Services for instance).
It can be fixed by setting ServicePointManager.SecurityProtocal globally for the Umbraco site, by overriding ApplicationStarted in a class inheriting from ApplicationEventHandler. For instance:
public class RegisterEvents : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
// Fix "Umbraco.Web.Scheduling.KeepAlive Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
if (ServicePointManager.SecurityProtocol.HasFlag(SecurityProtocolType.Tls12) == false)
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
}
}
For our Umbraco 8.6.2 environment, only TLS 1.2 is enabled using similar code, still have the KeepAlive errors. Viewing the log, the every-5-minutes KeepAlive error reads as follows:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
--- 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() in D:\a\1\s\src\Umbraco.Web\Scheduling\KeepAlive.cs:line 69
Beware that this also will ignore certificate errors for all other sites that you make calls to. Might not be that big an issue, since you have complete control of who and what you make http requests to 😉
If you're using Azure App Services, the service has a built-in "Always On" mode which achieves the same goal.
Since Umbraco 8.6 you can disable the keepAlive task if you'd wish to.
The configuration can be found in umbracoSettings.config:
<?xml version="1.0" encoding="utf-8" ?>
<settings>
...
<!--
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/api/keepalive/ping
Defaults to "{umbracoApplicationUrl}/api/keepalive/ping".
-->
<keepAlive disableKeepAliveTask="true" keepAlivePingUrl="{umbracoApplicationUrl}/api/keepalive/ping" />
</settings>
Last time I tried connecting to localhost on App Services, it denied on both HTTP/80 and HTTPS/443. I don't think the service allows you to do that.
This is from Azure Web App sandbox docs:
Rejected connection attempts, such as the following example which
attempts to connect to 127.0.0.1:80, from .NET will result in the
following exception: Exception Details: 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
ERROR Umbraco.Web.Scheduling.KeepAlive - Failed (at "https://localhost/umbraco")
Hello, I'm getting this issue too frequent on my Umbraco logs but I cannot find the real issue. This error repeats every 5 min (as you can see on the code). I'm working with Umbraco 7.6.3 hosted on a scaled out Azure Web App. I have custom UrlRewrites on my web.config
Can this rewrites screw the schedule publish of umbraco? This are the errors:
Hi Arlan,
Yes this can be an issue. Umbraco works be determining the connection it can use to communicate server side. Looking at your error message the URL it's trying to connect to is https://localhost/umbraco which is suspect you can't connect to from the server.
Can you check if
umbracoUseSSL
is set to true in the web.config as this may help. If you still have trouble after this you can hardcode the server side URL by settingumbracoApplicationUrl="http://localhost/umbraco"
in config/umbracoSettings.config.Hope that helps. Andy
Hello Andy, Thank you for your answer. I have umbracoUseSSL on true at the moment I post the issue. I will try with the
umbracoApplicationUrl="https://localhost/umbraco"
but I have a question here: Do I need to usehttp
orhttps
on the url?Hi Arlan,
I would try it without the https.
Thanks Andy
Hi,
I get the same error, but the proposed solution by setting umbracoApplicationUrl="http://localhost/umbraco" in config/umbracoSettings.config doesn't work for me. The error still appears every 2 minutes.
We are working with Umbraco 7.5.4 assembly: 1.0.6136.27241
Best regards, Nadine
I changed localhost to the sitename. Now it seems to be away.
On our Umbraco 8 site, I've tried the above (changing the web.routing line in umbracoSettings so that the umbracoApplicationUrl="https://ourwebsitename/umbraco"), but still getting the keepalive errors every 5 minutes. I also read it could be a TLS thing but we have TLS 1.0 and 1.1 turned off on our Windows 10 server. I've read about adding this line somewhere, not sure where it goes: System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12
Anyone have any more luck with this?
You have to make a composition something like below:
I think it is also covered more exhaustively at https://our.umbraco.com/documentation/Implementation/Composing/
I have umbraco version 7.14.0 and have a same problem with a subdomain
2020-02-13 00:08:42,607 [P9100/D2/T23] ERROR Umbraco.Web.Scheduling.KeepAlive - Failed (at "http://subdomain.domain.com/umbraco"). System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host.
Could any one help me please?.
This is due to the server running the Umbraco-site requiring TLS 1.2 connections (Azure App Services for instance).
It can be fixed by setting ServicePointManager.SecurityProtocal globally for the Umbraco site, by overriding ApplicationStarted in a class inheriting from ApplicationEventHandler. For instance:
For our Umbraco 8.6.2 environment, only TLS 1.2 is enabled using similar code, still have the KeepAlive errors. Viewing the log, the every-5-minutes KeepAlive error reads as follows:
Sounds like a self-issued or expired SSL-certificate. Or maybe the common name does not match the hostname?
You should be able to ignore the error by:
ServicePointManager.ServerCertificateValidationCallback += (o, c, ch, er) => true;
Beware that this also will ignore certificate errors for all other sites that you make calls to. Might not be that big an issue, since you have complete control of who and what you make http requests to 😉
If you're using Azure App Services, the service has a built-in "Always On" mode which achieves the same goal. Since Umbraco 8.6 you can disable the keepAlive task if you'd wish to. The configuration can be found in
umbracoSettings.config
:Last time I tried connecting to localhost on App Services, it denied on both HTTP/80 and HTTPS/443. I don't think the service allows you to do that. This is from Azure Web App sandbox docs:
I ended up disabling the keepAlive task and enabled "Always On". I ended up writing a blog post on the keep alive configuration here: https://swimburger.net/blog/umbraco/introducing-umbracos-keepalive-ping-configuration
Hope it helps!
is working on a reply...