Teamcity: Unable to connect the build agent?

It seems like we have a different problem every day. I was opening up the CI (TeamCity) site to public access so I did a bit of changes in Build agent configuration and TeamCity server configuration. After that, I am not able to connect the build agent from teamcity server.

Disconnected TeamCity Build Agent

Are you also having the same problem?

if yes then the first thing that you should check is the teamcity-agent.log file which is located under C:\BuildAgent\logs folder.

  • [2013-10-29 14:29:41,264] INFO – buildServer.AGENT.registration – Registering on server http:://localhost:5534, AgentDetails{Name=’my-agent-name’, AgentId=null, BuildId=null, AgentOwnAddress=’null’, AlternativeAddresses=[100.90.98.83], Port=9090, Version=’27540′, PluginsVersion=’27540-md5-5b7544cdf3432ba89ca2a172e2a1e21f’, AvailableRunners=[Ant, dotnet-tools-dupfinder, dotnet-tools-inspectcode, Duplicator, FxCop, gradle-runner, Inspection, Ipr, jb.nuget.installer, jb.nuget.pack, jb.nuget.publish, jetbrains.dotNetGenericRunner, jetbrains.mspec, jetbrains_powershell, JPS, Maven2, MSBuild, MSTest, NAnt, NUnit, rake-runner, simpleRunner, sln2003, VS.Solution], AvailableVcs=[perforce, mercurial, jetbrains.git, tfs, svn, cvs], AuthorizationToken=’c’}
  • [2013-10-29 14:29:41,312] WARN – buildServer.AGENT.registration – Call http:://localhost:5534/RPC2 buildServer.registerAgent3: org.apache.xmlrpc.XmlRpcClientException: Unexpected exception in client processing
  • [2013-10-29 14:29:41,313] WARN – buildServer.AGENT.registration – Connection to TeamCity server is probably lost. Will be trying to restore it. Take a look at logs/teamcity-agent.log for details (unless you’re using custom logging).

Do you see the error? Yes. There is two colons (http::localhost) in URL. You can open up the buildAgent.properties file under C:\BuildAgent\conf.

Here is the most typical buildAgent.properties file look like. After that, you can restart the “Team City Build Agent” service.

#Generated properties (see buildAgent.dist.properties for description)
#Tue Oct 29 14:17:24 UTC 2013
name=my-agent-name
ownPort=9090
serverUrl=http\://localhost\:5534
workDir=C\:\\BuildAgent\\work
tempDir=C\:\\BuildAgent\\temp
#User defined properties
#Tue Oct 29 14:17:24 UTC 2013
authorizationToken=c05cf77775ac4fb52321b3f23f66e882
env.TEAMCITY_JRE=C\:\\BuildAgent\\jre

WebDeploy 3 – Error in publishing website to Amazon EC2

Here is the error that I got when I publish website from Azure VM to Amazon EC2 VM. I am using the following MSBuild command to do the deployment and I got Web Deploy 3.0 installed on EC2 VM.

/p:Configuration=Release /p:OutputPath=bin /p:VisualStudioVersion=11.0 /p:DeployOnBuild=True /p:DeployTarget=MSDeployPublish /p:MsDeployServiceUrl=https://my-super-cool-server/msdeploy.axd /p:AllowUntrustedCertificate=True /p:DeployIisAppPath=YourWebSiteInstanceName /p:MSDeployPublishMethod=WMSVC /p:username=root /p:password=SuperComplexRootPassword

Error Message [VSMSDeploy] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(4196, 5): error ERROR_DESTINATION_NOT_REACHABLE: Web deployment task failed. (Could not connect to the remote computer (my-super-cool-server””). On the remote computer, make sure that Web Deploy is installed and that the required process (“Web Management Service”) is started. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINATION_NOT_REACHABLE.) [14:58:46][MyWebsite\MyWebsite.csproj.teamcity] Project MyWebsite\MyWebsite.csproj.teamcity failed. VSMSDeploy-update Solution As this post is not about how to use WebDeploy to deploy website, I am not going to write the detailed steps here. If you are new to using webdeploy, please read this post “Automating Deployment with Microsoft Web Deploy” The reason that I got this error is that the default for Web Management Service is not enabled by default in EC2. The solution is to enable the port 80 (which you might already enabled it for your website) for Web Deployment Agent and port 8172 for Web Management Service in both the server’s firewall and EC2 Security Group.

  • Web Deployment Agent Service : Port 80
  • Web Management Service : Port 8172

EC2 Security Group Hope it helps for those who are using MS deploy for publishing website on IIS. Reference:

Tips for setting up TeamCity with SQLExpress

Team City + SQL Express 2012

Jetbrains has a nice document for setting up an External Database but i run into a few problems and it took me a while to figure out it so I thought I could share it here and hope that it might be helpful for those who are having the same problem.

Here is the link for the installers and its versions.

The following are the issues that I faced when I was setting up the SQL express an external database for TeamCity.

Issues

  • teamcity SQL exception: Network error IOException: Connection refused: connect
  • SQL error when doing: Connecting to MSSQL: I/O Error: SSO Failed: Native SSPI library not loaded. Check the java.library.path system property.
  • SQL exception: Cannot open database “TeamCityDb” requested by the login. The login failed
  • Database is empty or doesn’t exist

Connection string in database.properties file

The string below is the connection string that I am using in database.properties file.

connectionUrl=jdbc:jtds:sqlserver://localhost:1433/TeamCityDb;instance=sqlexpress

Ok. I am going to share the problem/solution one by one here.

#1. Connection refused: connect

Error: teamcity SQL exception: Network error IOException: Connection refused: connect

Root cause: I got this error because JTDS JDBC driver connection string in database.properties file is using TCP/IP and SQL express comes with TCP/IP disabled by default.

Solution:

  1. Open SQL Configuration Manager
  2. Go to “Protocols for SQLExpress” under “SQL Server Network Configuration”
  3. Open the properties dialog of TCP/IP and select “Yes” for Enabled
    TCPIP in SQL Server Configuration Manager
  4. After that, go to “IP addresses” and set 1433 to “TCP port” property. Note: Please refer to my connection string above. I am using 1433 port but if you are using different tcp port then you need to set your port in this property.
    TCPIP in SQL Server Configuration Manager - 1

#2. Native SSPI library not loaded.

Error: SQL error when doing: Connecting to MSSQL: I/O Error: SSO Failed: Native SSPI library not loaded. Check the java.library.path system property.

Root cause:This error occurs because I am using windows authentication and I didn’t put the correct build of ntlmauth.dll. If you are using windows authentication, you need to copy ntlmauth.dll from \jtds-1.3.1-dist\x86\SSO\ folder to \TeamCity\bin folder. But I wrongly copied that dll from x64 folder instead of x86 so I was getting this error message.

Solution:   Copy ntlmauth.dll from \jtds-1.3.1-dist\x86\SSO\ folder to \TeamCity\bin folder. “x86” not “x64”.

#3. Cannot open database “TeamCityDb” requested by the login.

Error: 

Cannot open database “TeamCityDb” requested by the login. The login failed.
SQL query: connect
SQL exception: Cannot open database “TeamCityDb” requested by the login. The login failed

Root cause: There is no database called “TeamCityDb”  in SQL express.

Solution: Please create new database called “TeamCityDb” in SQL express.

#4. Database is empty or doesn’t exist

Error: Database is empty or doesn’t exist 

Error #2: Could not take a connection from data source: Cannot open database “TeamCityDb” requested by the login

Root cause: I am not very sure about it but the troubleshooting guide for Team City said that it’s something to do with database schema but I already gave the sysadmin role to “NT Authoriy\System” in SQL but still couldn’t solve the issue.

Solution: 

  1. You will see the error message below when you access the webapp of TeamCity. Please click on “I’m a server administrator. show me the details” link. It will ask you to enter the token. You can get the token under \TeamCity\logs\teamcity-server.log.
    TeamCity Database Creation - 2
  2. Enter the token and you will see this screen.
    TeamCity Database Creation
  3. Just click on “Proceed” and wait a few minutes while TeamCity is setting the settings.

Yap! Those are the issues that I faced when I was setting up SQL express for TeamCity. Hope you find it useful. Please feel free to share your TC tips/tricks with me and my blog readers too. Thanks!