MSDeploy 失败,并显示“远程主机强制关闭现有连接”

MSDeploy 失败,并显示“远程主机强制关闭现有连接”

提供给命令行的以下 MSDeploy 字符串会导致错误。有人能解释一下吗?

"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

堆栈跟踪:

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.

答案1

您是否在“计算机名称”上安装了 msdeploy 代理服务?

要安装它 - 您必须:
1) 从 iis.net 下载包
2) 安装管理服务(针对目标服务器上的 IIS)
3)配置管理服务(通过 ip 允许某些操作,注意:至少需要一个条目)
4)启动管理服务
5)启动代理服务
6)尝试部署

我确信它应该可以工作(我第一次尝试使用 msdeploy 时遇到此错误)

答案2

当管理服务使用的证书对于服务器无效时,我也看到了此“强制断开连接”错误消息。

就我而言,我创建了一个标准的 Web 服务器 VM,然后克隆了该 VM 的系统准备版本。克隆 VM 上的管理服务仍显示原始 VM 颁发的证书。

用自签名证书替换坏证书可以立即解决问题。

我最初花了几分钟才弄明白这一点……

答案3

IIS 10 服务器上刚刚遇到了这个问题。

我们从 CI 进行的远程部署返回了以下错误:

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.

几天前,我们执行了维护,安装了 Windows 更新并重启了服务器,之后发生了这种情况。管理服务处于在线状态,我尝试重启它,但它不允许部署工作。

使用的 SSL 证书直到 2027 年才到期,并且似乎已正确链接到服务。感谢上面的 @David-Montgomery 评论,这让我找到了正确的方向。

  1. 从服务器节点->服务器证书视图创建一个新的自签名证书(不管它是什么,它是临时的)
  2. 停止管理服务(转到服务器节点,然后转到功能视图底部管理组中的管理服务,然后双击该服务,并使用右侧面板中的停止)
  3. 将管理服务 (WMSVC) 上的 SSL 证书更改为您刚刚创建的自签名证书
  4. 在右侧申请并启动服务
  5. 再次停止服务
  6. 将 SSL 证书更改回之前使用的证书(假设该证书尚未过期)
  7. 再次申请并启动服务。
  8. 删除您创建的临时证书。

随后,管理服务似乎被重新绑定到 SSL 证书并且部署再次有效。

TLDR:由于某种原因,WMSVC 服务失去了与 SSL 证书的连接,即使 UI 显示它已链接?

相关内容