How to limit webdeploy connection number, ERROR_EX

2019-06-05 14:05发布

问题:

I have a solution that has 10-20 web projects, and I am trying to use msbuild webdeploy to deploy them.

msbuild "mysolution.sln" /p:DeployOnBuild=true /p:PublishProfile="Debug"

However, I got this error in the middle of deploy:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(4295,5): msdeploy error ERROR_EXCEEDED_MAX_SITE_CONNECTIONS: Web deployment task failed. (The maximum number of connections for this site has been exceeded.

In the log, before this error, a few projects were being deployed and files were updated. It seems that msbuild is trying to deploy as many as projects at the same time as possible, and exceeded the max connection number.

So how can I limit the connection number, is there an option in the publish profile?

Update - workaround

I have got a workaround from viet.hoang in Sitecore slack channel. It basically increases the max connection number on the server and/or retry attemps in the publish profile.

  1. Increase max connection number: go to the target server and add adding the following to the registry: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\3] "MaxSiteConnections"=dword:00000010. Then restart Web Management Service.
  2. Increase retry attempts: in the publish profile there is an option "RetryAttemptsForDeployment", add it and set the value to 20.

The workaround works, no more error in the deployment. But I am still hopeful that someone will be able to provide some insights and a proper solution that doesn't require registry modification and can throw other types of errors quickly without retry 20 times.

回答1:

Method 1 - Limit connection via MSBuild

There is a way to limit how many thread MSBuild can use.

msbuild.exe mysln.sln /maxcpucount:3  

The "maxcpucount" limits the MSBuild threads, thus limit how many projects can be published at the same time. If it is not defined, MSBuild will actually use up to the number of processors on the computer.

Reference: https://msdn.microsoft.com/en-us/library/bb651793.aspx

Method 2 - Lift limit on the server

Add a registry value to the server

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\3]

"MaxSiteConnections" (DWORD Value) : 0

Then restart "Web Management Service".

When you set the registry value to 0, it means unlimited connection.

Reference: Nicolas_nguyen1's comment in this Microsoft document



回答2:

I had the same problem when host by web deploy from visual studio 2017. after researching through online i had come across a solution . please follow the link: https://youtu.be/nOonbx9FgJQ