Thanasis Ioannidis
Thanasis Ioannidis

Reputation: 3231

Existing connection forcibly closed at Manage Extensions, VS 2019

Just installed vs2019 community on a fresh laptop.

Going to install some extensions and I see this

enter image description here

If I refresh several times, there is a change that I may see the extensions, but in the next refresh or when going to next page of extensions, I see the same thing.

No clue whatsoever on what is happening, why, and how to solve it.

UPDATE

I tried to install an extension from the marketplace site. It failed

enter image description here

I opened the logs and again, same error:

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()<---

UPDATE 2

Seems that even connection to the marketplace from browser is a problem

enter image description here

UPDATE 3 Having used Fiddler to inspect the problem further I get an HTTPS handshake failed.

UPDATE 4 While connecting to the internet through another WIFI network, the problem disappeared. More specifically I turned my mobile to a wifi hotspot and connected through the mobile. No more connection errors to visual studio marketplace...

UPDATE 5 - SOLUTION After I realized that the problem appeared in certain wifi networks and not always, I suspected that something wrong is going on with my wifi adapter settings. I removed ipv6 from my adapter settings and everything worked like a charm.

Upvotes: 9

Views: 2785

Answers (3)

Thanasis Ioannidis
Thanasis Ioannidis

Reputation: 3231

After reading a lot of different solutions to that problem, most of which were about configuration of proxy settings, I finally found what was causing the problem in my case.

None of the solutions I found worked. The only one close enough was a post about disabling ipv6 from visual studio's config file. Which I did but it seems the change was ignored. So I though ipv6 wouldn't be the root cause in my case and changed direction, but in vain.

When, at some point, I needed to connect to a different Wi-Fi network, I realized the problem was gone. Only in certain wi-fi I had this problem, and only on my laptop. Not any other of my devices. So I suspected there must be some combination of my laptop's Wi-Fi adapter settings and the Wi-Fi network that causes the problem.

Fiddling with the settings of my Wi-Fi network adapter, I found what I needed to do. I had to disable ipv6 from my Wi-Fi adapter settings.

And problem is gone.

enter image description here

In Windows 10 Control Panel in a section “Network and Sharing Centre” click "Change Adapter Settings" and open properties (right mouse click) of the adapter, that you are using(it may be Ethernet or Wi-Fi).

Upvotes: 15

cloudAIMLvs
cloudAIMLvs

Reputation: 59

Same problem for me but with Ethernet connection, and connection to Visual Studio Marketplace worked after unticking IPv6. Hopefully MSFT fixes this issue; IPv6 is the future. Makes no sense that the Marketplace server would not complete a TCP handshake simply because the client can use both IPv4 and IPv6.

Upvotes: 1

Nishant S Vispute
Nishant S Vispute

Reputation: 765

Based on your update 3 it seems that your TLS version is the root cause. Here is link to the MSDN Issue asking the same issue Link

Potential Fixes

  1. Update and enable TLS 1.1 / 1.2 on your New laptop (Usually done by installing the MS patches for the OS your using)

  2. Check the proxy setting in your project solution which is set by default by your VS.

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

Upvotes: 0

Related Questions