18

I deploy website through Teamcity using webdeploy method:

web.csproj /P:Configuration=%env.Configuraton% /P:DeployOnBuild=True /P:DeployTarget=MSDeployPublish /P:MsDeployServiceUrl=%env.DeployServiceUrl% /P:AllowUntrustedCertificate=True /P:MSDeployPublishMethod=WMSvc /P:CreatePackageOnPublish=True /P:UserName=%env.DeployUserName% /P:Password=%env.DeployPassword%

The error I recieve constantly:

[MSDeployPublish] VSMSDeploy (35s) [VSMSDeploy] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.5\Web\Microsoft.Web.Publishing.targets(4196, 5): error ERROR_EXCEEDED_MAX_SITE_CONNECTIONS: Web deployment task failed. (The maximum number of connections for this site has been exceeded. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_EXCEEDED_MAX_SITE_CONNECTIONS.)

On Teamcity agent installed Visual Studio 2010 Express, .netf framework version: 4.0

Pankwood
  • 1,799
  • 5
  • 24
  • 43
Yevgen Safronov
  • 3,977
  • 1
  • 27
  • 38

5 Answers5

25

I have fixed this problem by restarting the Web Management Service in Services.

FAHID
  • 3,245
  • 3
  • 18
  • 15
  • 1
    This solution also worked for me on the error "Invoke build failed due to exception 'There is a build already in progress. Please try again later.'" – Jon Schneider Jul 31 '15 at 19:13
  • 1
    On a French server, look for "Service de gestion Web" (don't know why they translate this kind of stuff, it's more complicated to apply existing solutions) – youen May 09 '16 at 09:52
  • This isn't a fix/solution. It's a work around. It'll also work if we reboot the server, but that's also not a fix/solution. – John Rocha Apr 18 '17 at 22:41
  • 1
    When I tried this the Web Management Service hung and would not shut down. – Mike Jun 26 '18 at 03:55
  • Web Management Service hung so I killed the process, it automatically restarted and the problem went away. – Ian Warburton Oct 19 '18 at 13:11
2

I've also come across this approach to allow an unlimited number of connections:

1.) Add the following registry key:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\3]
"MaxSiteConnections"=dword:00000000

2.) Restart Web Management Service

Reference: Nicolas_nguyen1's comment on this Microsoft document

Source: How to limit webdeploy connection number, ERROR_EXCEEDED_MAX_SITE_CONNECTIONS

UPDATE

I was able to test this myself and it seemed like Web Deploy treated this value as literally "0" connections allowed, which resulted in this error occurring every time. So I set it to 0x7FFFFFFF (maximum for a 32 bit integer).

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\3]
"MaxSiteConnections"=dword:7FFFFFFF
marsze
  • 15,079
  • 5
  • 45
  • 61
1

I investigated the problem on the both ends: hosting web server and build machine( Visual Studio 2010 Express SP1 installed from web installer) from which I initiate deployment. Restart of the team city server and agents (problem reproduced on 2 agents) didn't help. I've installed team city agent on local machine and deployed successfully from it. Then I compared successful and failed build logs. The interesting part is the source of the error:

C:\Program Files(x86)\MSBuild\Microsoft\VisualStudio\v10.5\Web\Microsoft.Web.Publishing.targets

On my local machine (Visual Studio Ultimate 2010 with SP1) a have only

MSBuild\Microsoft\VisualStudio**v10**\Web\Microsoft.Web.Publishing.targets

so my quick solution was to test deployment using that method on build agents. I've replaced content of the

C:\Program Files(x86)\MSBuild\Microsoft\VisualStudio\v10.5\Web\

with

C:\Program Files(x86)\MSBuild\Microsoft\VisualStudio\v10\Web\

and that resolved the problem. I don't know why but deployment worked correctly on build agents previously.

Yevgen Safronov
  • 3,977
  • 1
  • 27
  • 38
0

I had this same issue today on a new TeamCity build I was setting up. Builds are using Web Deploy to publish two MVC4 applications to test servers on the local network on a nightly schedule.

In my case, the error was due to having the "Trigger build on all enabled and compatible agents" option checked on the build's Schedule Trigger in TeamCity. We have four build agents and having that option checked was starting four builds at the same time. Two of the builds succeeded and two failed with the ERROR_EXCEEDED_MAX_SITE_CONNECTIONS error.

Pankwood
  • 1,799
  • 5
  • 24
  • 43
Chris Morgan
  • 1,074
  • 11
  • 11
0

I have also encountered this error and I researched two ways to solve it. This is my original question, but I think this question is more easily searchable than mine, so I will repost my findings here to help others: https://stackoverflow.com/a/49140311/4228027

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

EthanX
  • 185
  • 1
  • 9