我们在 Azure 中有两个具有这种配置的环境(都位于西欧):
测试:
- 应用服务(基本计划 1)
- SQL 数据库(在标准 S0 上)
- CDN(在标准 Verizon 上)
阶段:
- 应用服务(计划标准 1)
- SQL 数据库(在标准 S3 上)
- CDN(在标准 Verizon 上)
我们部署了相同的基于 Umbraco + uCommerce 的 Web 应用程序代码,但在 Stage 环境中的性能比在测试环境中要差得多。性能最差的是使用 uCommerce API 的页面。Umbraco 和 uCommerce 中的内容是相同的。后端处理时间在测试上小于 1 秒,在舞台上约为 20 秒。我们找不到这些环境之间的配置差异。我可能有什么问题?我们如何才能找到导致问题的原因?
编辑:
即使 AzureCDNToolkit:CdnUrl 值有效,Umbraco 日志也会显示大量此类错误:
2018-07-30 13:07:20,429 [P9292/D2/T31] ERROR Our.Umbraco.AzureCDNToolkit.UrlHelperRenderExtensions - Error resolving media url from the CDN
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> 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
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at Our.Umbraco.AzureCDNToolkit.UrlHelperRenderExtensions.<>c__DisplayClass6_1.b__0()
at Our.Umbraco.AzureCDNToolkit.UrlHelperRenderExtensions.TryFiveTimes(Action delegateAction)
at Our.Umbraco.AzureCDNToolkit.UrlHelperRenderExtensions.UrlToCdnUrl(String cropUrl, Boolean htmlEncode, String currentDomain)
编辑
一段时间后我发现了一个问题:Azure 使用 TLS 1.2 作为 Azure 服务的默认配置,因此为了使其正常工作,我所要做的就是在应用程序启动时添加这一行:
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;