现有连接在 Manage Extensions,VS 2019 中被强行关闭

Existing connection forcibly closed at Manage Extensions, VS 2019

刚刚在一台新的笔记本电脑上安装了 vs2019 社区。

要安装一些扩展,我看到了这个

如果我刷新几次,我可能会看到扩展,但在下一次刷新或转到下一页扩展时,我会看到同样的东西。

对发生的事情、原因以及解决方法一无所知。

更新

我试图从 marketplace 站点安装扩展。失败了

我再次打开日志,同样的错误:

14/05/2021 17:52:17 - One or more errors occurred.
14/05/2021 17:52:17 -    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Microsoft.VisualStudio.ExtensionManager.VSGalleryRepository.GetExtensions[T](List`1 extensionIds, Int32 lcid, Boolean forAutoupdate)
   at VSIXInstaller.ExtensionPackService.GetExtensionByVsixId(List`1 vsixIds, String extensionPackParentName, IExtensionEngine extensionEngine, List`1 extensionsToInstall, CancellationToken cancellationToken)
14/05/2021 17:52:17 - END: Gathering extension pack information
14/05/2021 17:52:17 - END: Processing extension pack
14/05/2021 17:52:17 - System.AggregateException: One or more errors occurred. ---> 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 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.EndReceive(IAsyncResult asyncResult)
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
   --- End of inner exception stack trace ---
   at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
   at System.Net.PooledStream.EndWrite(IAsyncResult asyncResult)
   at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
   at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(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 Microsoft.VisualStudio.ExtensionManager.VSGalleryRepositoryHelper.<PostAndGetResponseAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ExtensionManager.VSGalleryRepository.<>c__DisplayClass14_0`1.<<GetExtensionsOrCategoriesAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ExtensionManager.VSGalleryRepository.<GetExtensionsOrCategoriesAsync>d__14`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ExtensionManager.VSGalleryRepository.<GetExtensionsAsync>d__13`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ExtensionManager.VSGalleryRepository.<>c__DisplayClass12_0`1.<<GetExtensions>b__1>d.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Microsoft.VisualStudio.ExtensionManager.VSGalleryRepository.GetExtensions[T](List`1 extensionIds, Int32 lcid, Boolean forAutoupdate)
   at VSIXInstaller.ExtensionPackService.GetExtensionByVsixId(List`1 vsixIds, String extensionPackParentName, IExtensionEngine extensionEngine, List`1 extensionsToInstall, CancellationToken cancellationToken)
   at VSIXInstaller.ExtensionPackService.AcquireExtensionPack(IList`1 extensionsPath, IStateData stateData, Boolean isRepairSupported)
   at VSIXInstaller.ExtensionPackService.ExpandExtensionPackToInstall(IStateData stateData, Boolean isRepairSupported)
   at VSIXInstaller.App.Initialize(Boolean isRepairSupported)
   at VSIXInstaller.App.Initialize()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
---> (Inner Exception #0) 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 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.EndReceive(IAsyncResult asyncResult)
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
   --- End of inner exception stack trace ---
   at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
   at System.Net.PooledStream.EndWrite(IAsyncResult asyncResult)
   at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
   at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(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 Microsoft.VisualStudio.ExtensionManager.VSGalleryRepositoryHelper.<PostAndGetResponseAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ExtensionManager.VSGalleryRepository.<>c__DisplayClass14_0`1.<<GetExtensionsOrCategoriesAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ExtensionManager.VSGalleryRepository.<GetExtensionsOrCategoriesAsync>d__14`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ExtensionManager.VSGalleryRepository.<GetExtensionsAsync>d__13`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ExtensionManager.VSGalleryRepository.<>c__DisplayClass12_0`1.<<GetExtensions>b__1>d.MoveNext()<---

更新 2

似乎连从浏览器连接到市场也是个问题

更新 3 使用 Fiddler 进一步检查问题后,我发现 HTTPS 握手失败。

更新 4 通过另一个WIFI网络连接到互联网时,问题消失了。更具体地说,我将手机设置为 wifi 热点并通过手机连接。 visual studio 市场没有更多的连接错误...

更新 5 - 解决方案 在我意识到问题出现在某些 wifi 网络中但并非总是如此之后,我怀疑我的 wifi 适配器设置出了问题。我从我的适配器设置中删除了 ipv6,一切都很顺利。

根据您的 更新 3,您的 TLS 版本似乎是根本原因。这是 link 到 MSDN Issue 询问同样的问题 Link

潜在修复

  1. 在您的新笔记本电脑上更新并启用 TLS 1.1/1.2(通常通过为您使用的 OS 安装 MS 补丁

  2. 检查你的项目解决方案中的代理设置,这是你的VS默认设置的。

    #Ref MSDN, Whosebug, How to configure proxy setting in vs

在阅读了很多针对该问题的不同解决方案(其中大部分是关于代理设置的配置)之后,我终于找到了导致我的问题的原因。

None 我发现的解决方案有效。唯一足够接近的是 post 关于从 visual studio 的配置文件中禁用 ipv6。我这样做了,但似乎更改被忽略了。所以我虽然 ipv6 不会是我的情况的根本原因并改变了方向,但徒劳无功。

当我有时需要连接到不同的 Wi-Fi 网络时,我意识到问题已经解决了。只有在某些 wi-fi 中我有这个问题,而且只在我的笔记本电脑上。不是我的任何其他设备。所以我怀疑一定是我的笔记本电脑的 Wi-Fi 适配器设置和导致问题的 Wi-Fi 网络的某种组合。

摆弄我的 Wi-Fi 网络适配器的设置,我找到了我需要做的事情。 我不得不从我的 Wi-Fi 适配器设置中禁用 ipv6

问题解决了。

在 Windows10 控制面板的“网络和共享中心”部分中单击“更改适配器设置”并打开您正在使用的适配器的属性(单击鼠标右键)(它可能是以太网或 Wi-Fi)。

我遇到了同样的问题,但以太网连接和到 Visual Studio Marketplace 的连接在取消勾选 IPv6 后工作正常。 希望 MSFT 解决这个问题; IPv6 是未来。 仅仅因为客户端可以同时使用 IPv4 和 IPv6,Marketplace 服务器不会完成 TCP 握手是没有意义的。