1

2019 新年在我下面的 Visual Studio 2015 代码中带来了这个调试异常。唯一可行的是运行已编译的 EXE 或使用具有相同 Internet 第三方 API 调用的 Visual Studio 2010。我们已经安装了更新的 Symantec Endpoint Protection,我们进行了各种调整,但周日无济于事。我的同事卸载了赛门铁克,我们都多次重新启动,但都没有缓解。

2019-01-03 08:56:47.3326|ERROR|...:
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.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
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.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.TlsStream.CallProcessAuthentication(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean reserveSyncCtx)
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.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)

--- 内部异常堆栈跟踪结束 ---

at System.Net.HttpWebRequest.GetResponse()
4

1 回答 1

0

问题开始的同一天是我们的第三方 Web API 提供商停止支持 TLS 1.0 的同一天。据我了解 TLS,Windows 10 和 Visual Studio 2015 将默认为 TLS 1.0。快速修复是在第一个 API 调用之前使用此 VB.NET 代码:ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

从长远来看,我们将消除每个 Microsoft 的 WebRequest 调用:“重要

我们不建议您使用 WebRequest 或其派生类进行新开发。相反,请使用 System.Net.Http.HttpClient 类。”

于 2019-01-14T22:15:06.340 回答