3

The following MSDeploy string supplied to the command line results in an error. Can anyone shed any light on this?

"C:\Program Files\IIS\Microsoft Web Deploy\\msdeploy.exe" -source:package='D:\dev\Project\obj\BuildConfiguration\Package\Project.zip' -dest:auto='Website Name',computerName='computername',userName='username',password='password' -verb:sync -enableRule:DoNotDeleteRule -allowUntrusted -debug

Stack trace:

Microsoft.Web.Deployment.DeploymentAgentUnavailableException: Could not complete the request to remote agent URL 'http://computername/MSDEPLOYAGENTSERVICE'.
---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> 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.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.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)    at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)    --- End of inner exception stack trace ---    at System.Net.HttpWebRequest.GetResponse() at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponse(HttpWebRequest request)    --- End of inner exception stack trace ---    at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponse(HttpWebRequest request)    at Microsoft.Web.Deployment.AgentClientProvider.CreateStatusThread(DeploymentSyncContext syncContext)    at Microsoft.Web.Deployment.AgentClientProvider.RemoteDestSync(DeploymentObject sourceObject, DeploymentSyncContext syncContext)    at Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable)    at Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)    at MSDeploy.MSDeploy.ExecuteWorker() Error count: 1.
3

Did you installed on 'computername' - msdeploy agent service?

To install it - you must:
1) download package from iis.net
2) install management service (for IIS on DEST server)
3) configure management service (to allow by ip something, note: there is required AT LEAST ONE entry)
4) start management service
5) start agent service
6) try deployment

I'm sure it should work (I've encounter this error when tried to use msdeploy for first time)

3

I've also seen this 'forcibly disconnected' error message when the certificate used by the management service is invalid for the server.

In my case, I created a standard web server VM, then cloned a sysprepped version of the VM. The management service on the cloned VM's was still displaying a certificate issued by the original VM.

Replacing the bad certificate with a self-signed certificate clears the problem right up.

It took me a few minutes to figure that one out initially...

0

Just had this issue on an IIS 10 server.

Our remote deploy from CI was returning the following error:

07-Mar-2019 11:36:21    Info: Using ID 'fc4e2c45-1368-4487-aff2-60cbb3cde2f6' for connections to the remote server.
07-Mar-2019 11:36:22    Error: Could not complete the request to remote agent URL 'https://anonymous-server.co.nz:8172/msdeploy.axd?site=anonymous-site.co.nz'.
07-Mar-2019 11:36:22    Error: The underlying connection was closed: An unexpected error occurred on a send.
07-Mar-2019 11:36:22    Error: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
07-Mar-2019 11:36:22    Error: An existing connection was forcibly closed by the remote host
07-Mar-2019 11:36:22    Error count: 1.

This occurred after a maintenance window we performed a few nights ago, installing windows updates and rebooting the server. The management service was online and I attempted to restart it however it did not allow deployments to work.

The SSL certificate in use did not expire until 2027 and appeared to be linked to the service correctly. Thanks to @David-Montgomery comment above, this lead me in the right direction.

  1. Create a new self-signed certificate from the server node -> server certificates view (doesn't matter what it is, it's temporary)
  2. Stop the management service (by going to the server node, then to Management service in the management group at the bottom of the features view, then double clicking on that, and using stop in the right hand panel)
  3. Change the SSL certificate on the management service (WMSVC) to be the self signed cert you just created
  4. Apply & start the service on the right hand side
  5. Stop the service again
  6. Change the SSL certificate back to the one that was in use previously (assuming it's not expired)
  7. Apply & start the service again.
  8. Delete the temporary certificate you created.

Following this, the management service appears to be rebound to the SSL certificate and deployments work again.

TLDR: for some reason the WMSVC service lost it's connection to the SSL certificate even though the UI showed it as linked?

1
  • 2
    Additionally, invalid TLS settings can cause a similar or identical issue. If the server has disabled for example TLS1.0 but your client (Visual Studio) tries to use 1.0, it will fail with the same message. You can force VS to use TLS1.2 by making the changes described here support.microsoft.com/en-us/help/3206898/… Apr 26 '19 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.