Я знаю, что этот вопрос задавался много раз прежде, но я не могу найти свой точный сценарий.
Мой сайт работает на трех веб-серверах через балансировщик нагрузки. Эта ошибка происходит только на одном из трех серверов. Я проверил. NET версии всех трех, и все они совпадают (. NET Framework 4.7.2), и я также проверил настройки реестра для SecurityProviders [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Client]
, и снова они все одинаковые.
Вот ошибка, которую я получаю
Message: The underlying connection was closed: An unexpected error occurred on a send.
System.Net.WebClient.DownloadFile(Uri address, String fileName):202
Eteach.Client.Web.Controllers.WebAPI.ApplicationController.DownloadApplicationFiles(Int32 AppId) in D:\TeamCity\buildAgent\work\6428a4815697ed89\Eteach.Client.Web\Controllers\WebAPI\ApplicationController.cs:1681
Message: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size):236
System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count):17
System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest):55
System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest):113
System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest):77
System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult):275
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx):121
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx):9
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state):52
System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result):413
System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size):13
System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size):45
System.Net.ConnectStream.WriteHeaders(Boolean async):201
Message: An existing connection was forcibly closed by the remote host
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size):157
Вот мой код:
using (var webClient = new WebClient())
{
fileExtension = ApplicationDetailsPath.Substring(ApplicationDetailsPath.LastIndexOf("."));
string cfilePath = ApplicationDetailsPath;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
webClient.DownloadFile(new Uri(cfilePath), filepath + "/ApplicationForm" + fileExtension);
}
Любые предложения относительно того, что я должен смотреть дальше?