chocolatey / choco

Chocolatey - the package manager for Windows
https://chocolatey.org
Other
10.31k stars 904 forks source link

An existing connection was forcibly closed by the remote host #1029

Open cmanon opened 7 years ago

cmanon commented 7 years ago

I'm trying to use packer/vagrant to provision a windows 2016 box, using VirtualBox 5.1.8 and also tested with 5.0.28 using basically these scripts https://github.com/mwrock/packer-templates.

Chocolatey install correctly, but trying to use any command gives the error showed on the gist below when using the VirtualBox network interface as NAT, but if I switch the network as bridged and associate it to my computer interface chocolatey work as expected.

I also have tried using http instead of https and get the same issue.

Host: OSX 10.11.16 VirtualBox: 5.0.28/5.1.8 Chocolatey: 0.10.3

https://gist.github.com/cmanon/81a6db97d5e40d999d337dcaceb1e2ef

Any pointers would be a appreciated.

ferventcoder commented 7 years ago

That's a pretty nasty looking error. Do you see this with everything you try to install?

ferventcoder commented 7 years ago

What version of Vagrant by the way?

ferventcoder commented 7 years ago

Also, if you can install fiddler and then run it with this and include the saz report, it will be helpful to determine the issue.

cmanon commented 7 years ago

Do you see this with everything you try to install?

Yes, every command throw that error.

What version of Vagrant by the way?

1.8.5

I will do the test with fiddler.

I also did some more testing with other VirtualBox versions, installed the latest 4.3 series and with the NAT network configured it works perfectly, I'm actually building the vm image at this time.

ferventcoder commented 7 years ago

I'm also on Vagrant 1.8.5 and Virtualbox 5.0.28. I'm not seeing the same error, but then again I'm still working to keep vagrant from destroying my Windows Server 2016 box as it is finishing the provisioning and runs into an error. (It's a feature :/)

ferventcoder commented 7 years ago

Add this line and tell me if you still get the issues? https://github.com/ferventcoder/vagrant-windows-puppet/blob/32184a6c4e2e2ad43141cb6083209f64e911eed2/boxes/VagrantWindows.rb#L14.

ferventcoder commented 7 years ago

Not sure if you are seeing the issue during the packer build or the vagrant box use. I was guessing the latter, so feel free to correct me if I'm wrong.

cmanon commented 7 years ago

I'm experiencing on both, with provisioning and also when running the vm with vagrant, I added the line you mentioned and the issue persist, here's the output of the packer script.

https://gist.github.com/cmanon/41b817fd1b2a9d55186a786201fb0c9f

ferventcoder commented 7 years ago

I also did some more testing with other VirtualBox versions, installed the latest 4.3 series and with the NAT network configured it works perfectly, I'm actually building the vm image at this time.

This (and the logs) make me think that the issue lies somewhere in not having network access within the Virtualbox VM. Are you able to use other things that need network access that are not choco?

pammacdotnet commented 7 years ago

Have the same problem... I can use the network and even ping from cmd.exe, but command "choco list" fails with the same error (unable to read data from transport connection).

bhazard commented 7 years ago

I am also seeing this error; however, choco list is not alone. Same issue with azure command line (azure login failed with similar error). Both work in bridge mode, but not NAT. My issue was definitely not related to chocolatey. Virtualbox 5.1.8, Host OSX 10.11.6.

cmanon commented 7 years ago

As others mentioned, I can browse the web in the VM and do pings.

bhazard commented 7 years ago

@cmanon, so can I (in NAT or bridge mode). The two modes are the same in that regard, but not in how outside services (such as choco and azure) talk back to the guest. From vbox: "NAT - Your host will act as a router (firewall) and your hosts will be on a private subnet. Use this if you are not running servers on the guests. Bridged - Your guests will get a ip address on the same subnet as your host. ... As the name implies, with this option you can connect to the guest servers from the host only." So seems that choco tries to create a return connection and the host isn't routing it correctly (or the host firewall is blocking it).

ferventcoder commented 7 years ago

If someone can grab a fiddler report from the guest and attach it, that would be great!

bhazard commented 7 years ago

Here is my guest fiddler2 output, but I think comms is getting lost outside of the guest so I don't believe we will see anything useful in guest fiddler. Either way, here is what I see.

NAT Interface With fiddler2 enabled and NAT interface, my choco list hangs (I might expect that). The unhappy fiddler output: https://gist.github.com/bhazard/727a6ced0d1477eadd0b24f8f64a339e

Without fiddler2, the choco list command line output is: choco list
Chocolatey v0.10.3
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

(and as noted, with fiddler, it hangs so produces no output).

Bridge Interface
With bridge networking, the choco list completes and lists as expected. The happy fiddler output is: https://gist.github.com/bhazard/71ad20abff2b7fa0f0105b743ce2ffd3

Could be my host network settings ... I have my mac firewall disabled, but could be other differences.

matt-richardson commented 7 years ago

I'm hitting the same issue with Vagrant 1.8.6, VirtualBox 5.0.28 r111378, and chocolatey0.10.3`. I'm hitting it with an vagrantfile very similar to https://github.com/mefellows/vagrant-dsc/blob/master/development/web/Vagrantfile.

cmanon commented 7 years ago

@bhazard I don't think it has to do with the host network settings because without changing anything on the host network it works for me with VirtualBox 4.3 in NAT mode.

bhazard commented 7 years ago

@cmanon ... just to confirm my understanding ... virtualbox 5.x with NAT did not work for you, but 4.3 with NAT does? I only tried with vbox 5.1.8. In any case, still seems a networking issue to me (I had two different apps having what I believe is the same issue). Routing for bridge is much simpler, and cuts both host settings and virtualbox routing out of the picture. Is bridge mode not an option for you?

cmanon commented 7 years ago

@bhazard Your statement is correct, 4.3 NAT works, 5.0 or 5.1 NAT does not work. Once running bridge works for me, but for the provisioning with packer it makes it really hard.

jbarnett-r7 commented 7 years ago

We're also seeing this same issue. I did not experience it on VirtualBox 5.1.6 but others in the office were reporting it. After some troubleshooting and looking into differences between setups it showed that we had different VirtualBox versions. I upgraded to 5.1.8 and immediately started seeing the same problem.

We're using varying versions of Vagrant, from 1.8.5 to 1.8.7, and Chocolatey 0.10.3. Unfortunately switching to bridged isn't a very good option since we're using this to build a VM that is full of vulnerabilities.

ferventcoder commented 7 years ago

Best thing I can recommend is to downgrade to a VirtualBox version that doesn't not experience issues like this. I'm in VBox 5.0.x and not seeing this issue either. It may also help to see if there is a bug with NAT in the latest versions of VirtualBox or file one if they don't already have a bug report.

jbarnett-r7 commented 7 years ago

Yeah this looks to be a VirtualBox bug. I found this bug on their issue tracker and installed the recommended build, 5.1.9 r 111846, and ran the Vagrant provisioner again and all of my Chocolatey packages are installing correctly.

Currently that VirtualBox build is just a test release, but hopefully the fix will be rolled out with the next full GA release.

bhazard commented 7 years ago

@jbarnett-r7 - good find -- that looks like it would explain what folks are reporting and what I saw. Thanks for the update.

tokra commented 7 years ago

Same issue on my virtual box/win10/chocolatey