Challenge:
If you are using Visual Studio one click publish, and you are facing following error (We were getting it while doing publish from Build server to Target server.)
Web deployment task failed. (Could not complete the request to remote agent URL ‘https://<HOSTNAME/IP>:8172/msdeploy.axd?site=<OURWEBSITE>’.)
This error indicates that you cannot connect to the server. Make sure the service URL is correct, firewall and network settings on this computer and on the server computer are configured properly, and the appropriate services have been started on the server.
Error details: Could not complete the request to remote agent URL ‘https://<HOSTNAME/IP>:8172/msdeploy.axd?site=<OURWEBSITE>’.
The underlying connection was closed: An unexpected error occurred on a send.Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host 0 0 WEBSITENAME
Or any other error related to Web Deploy [a.k.a. MsDeploy] technology used behind the scenes of Visual studio publish. Then this post is for you!
Solution:
This is the error, Which took days and days for us. Because all settings were working since couple of years and suddenly it stopped working. Without getting any clue. This is what we did for troubleshooting:
- Disable Firewall/Antivirus, Allow Port 8172
- Make sure Hostname/IP gets resolved
- Server’s IP and Port number is reachable : Yes – We verified it using Telnet and it can connect to Port 8172 and also verified Firewall rules as well – All good!
- Verified all Web deploy related services are fine or not – and they are fine – We tried to run Powershell script given by Microsoft in Reference Link #2 – But no luck
- Verified username and password are fine – They are fine – Verified it using remote desktop with those credentials
- Reinstalled MSDeploy on SBX – and It didn’t helped
- No any log entry in MS Deploy IIS Log [HEAD/POST]
- Tried with MSDeploy command : msdeploy.exe -verb:dump -source:iisapp=”Default Web Site”,computername=https://:8172/msdeploy.axd?site=Default%20Web%20Site,username=,password=,authType=basic -verbose –whatif
- Fired MS deploy command from my local – as given in earlier email and monitored packets on SBX server using TCPView and netstat command : Found that : TCP Packet gets sent on 8172 and status : SYNC_RCVD – and then it drops packet
During this whole process. This is what we understood:
– Web Management Service listens on 8172
– If request received it calls MsDeploy.axd
Somehow, packet gets reached to Machine – But after that it should forward it to IIS – And in turn IIS will send it to MsDeploy – And looking at log files – Packet is being dropped at machine level
- http://forums.iis.net/t/1227905.aspx?The+underlying+connection+was+closed+An+unexpected+error+occurred+on+a+send+
- http://stackoverflow.com/questions/12959501/web-deployment-task-failed-when-using-webdeploy-in-vs2012
- http://www.iis.net/learn/publish/troubleshooting-web-deploy/troubleshooting-web-deploy-problems-with-visual-studio
- http://stackoverflow.com/questions/5841370/cant-get-my-ec2-windows-server-2008-web-stack-instance-to-receive-publishings
- http://stackoverflow.com/questions/11479927/visual-studio-2012-web-deploy-to-windows-server-2008-r2-with-iis-7-and-msdeploy
- http://www.asp.net/web-forms/overview/deployment/configuring-server-environments-for-web-deployment/configuring-a-web-server-for-web-deploy-publishing-(web-deploy-handler
- http://stackoverflow.com/questions/10894671/msdeploy-fails-for-webdeploy
- http://blogs.msdn.com/b/amol/archive/2011/02/09/errors-seen-while-using-msbuild-to-deploy-on-a-remote-iis-server-and-their-solutions.aspx
We raised ticket with Microsoft Support folks and this has been fixed by changing Server URL to : http://<HOSTNAME/IP> from : https://<HOSTNAME/IP>:8172/msdeploy.axd [Reference link : https://msdn.microsoft.com/en-us/library/dd465337%28v=vs.110%29.aspx]
To be honest — We haven’t been able to find out why earlier URL was working earlier and not working now!
Wow nice workout sir will be helpful to us
Regards,
Shivam Shah
IT professional & Web Developer
Bachelor of Computer Application
Ph. 519-331-5260
>
One thing I ran into is WebDeploy (as of v3.6) stops working if TLS 1.0 is disabled. So if you’ve disabled TLS 1.0 and earlier for PCI compliance or as a best practice then you will hit this. By using http:// you are not using SSL/TLS which would bypass any TLS issues, and I believe that you end up using the older MSDEPLOYAGENTSERVICE service instead of msdeploy.axd as well.
Sounds good. Thanks for sharing!
[…] Because I have spent good amount of time troubleshooting it (and before that understanding it) and this post is proof of […]
I’d like to share something that tortured me for some hours: In case you have disabled some ciphers using tools such as IIS Crypto, there will be problems with SSL negotiation from within VS.
This will result in getting the message:
The underlying connection was closed: An unexpected error occurred on a send.
Create this .reg file as mentioned on the link below, run it, close VS and reopen.
http://www.diaryofaninja.com/blog/2016/02/28/pci-compliant-web-deploy-getting-webdeploy-working-after-disabling-insecure-ciphers-like-ssl-30-and-tls-10