Activate cloud license for Episerver 7.5 site
[GetCloudLicense] The underlying connection was closed. An unexpected error occurred on a receive.
Overview
We were migrating site from on-premises server to Azure VM for our healthcare client. The site was in EPiServer 7.5 and using below System requirements.
- Operating system -> Microsoft Windows Server 2012 R2
- Web server -> Microsoft Internet Information Services (IIS) 7.0
- Database -> Microsoft SQL Server 2008 R2
- Framework -> Microsoft .NET Framework 4.5, C# 5.0
For on-premises servers, we were having fixed IP Address, and its license file was based on IP Address.
But in case of moving to Azure VM, we reached out to Optimizely License team, to get Cloud License and added it under project’s root folder. This will load the Cloud License tab under Admin->Config->Manage websites and we were trying to configure it using below article.
But while changing tab from websites to Cloud License, we got the error saying [GetCloudLicense] The underlying connection was closed. An unexpected error occurred on a receive. as shown in below screenshot.
Above error occurred because EPiServer 7.5 support .net framework version 4.5 (System-Requirements) and it uses TLS 1 and TLS 1.1 for network handshaking.
But TLS 1 and TLS 1.1 are effectively deprecated as of 2020 and hence we must use TLS 1.2 for network handshake to prevent above error.
To activate cloud license, we are using cloud-api.episerver.com service which in turn uses TLS 1.2 for network handshake.
Due to difference in TLS versions at source and destination, the network handshake is failing which is causing the issue.
Solution
In order to resolved this issue we are forcing .net framework 4.5 to use TLS 1.2 for network handshake by adding below line in Global.asax.cs file’s Application_Start() method.
protected void Application_Start() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; }
This should resolve the issue.
If you are still facing the issue then make sure your firewall is not blocking licensing service on port 443 (SSL) for cloud-api.episerver.com and your server should easily communicate with cloud-api.episerver.com:443 (SSL)