This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.

Issue

When K2 is configured to use SQL Server alias and SQL is hosted on a separate machine from the K2 server, the K2 Server service fails to start after upgrade to 5.3, when K2 Configuration Service is up and running.

NOTE: This issue only occurred when you use initial version of K2 5.3 installer (5.0004.1000.1), updated installer (5.0004.1000.2) which addressed this issue is already available for download and old installer has been removed from the portal. You can see information on installer specific fixes in K2 Five (5.3) release notes under "Installer Resolved Items in K2 Five (5.3) (5.0004.1000.2)" section.

 

Symptoms

When attempting to start the K2 Server service using Services snap-in, you receive a warning message "The K2 Server service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs." as shown on the screenshot below:

Image

When starting K2 Server service in console mode the following error is displayed:

Image

Console output text:

Debug 1013 Creating Instance: SourceCode.CloudLinkService.CloudLinkService Debug 1015 Enrolling Instance : SourceCode.CloudLinkService.CloudLinkService Error 2001 Error Starting Host Server: System.NullReferenceException: Object reference not set to an instance of an object. at SourceCode.CloudLinkService.Badger.BadgerLinkService.Initialize(IServiceMarshalling serviceMarshalling, IServerMarshaling serverMarshalling) at SourceCode.CloudLinkService.CloudLinkService.TryInitialize() at SourceCode.Hosting.Server.Runtime.HostServerEngine.EnrollHostableTypeInstance(IHostableType HostableTypeInstance) at SourceCode.Hosting.Server.Runtime.HostTypeLoader.InitAndEnrollHostableType(String HostedTypeName, String InterfaceName) at SourceCode.Hosting.Server.Runtime.HostTypeLoader.InitAndEnrollHostableTypes(String InterfaceName) at SourceCode.Hosting.Server.Runtime.HostServerEngine.StartHostServer();Error Invoking 'StartHostServer' : SourceCode.HostServerLib : Object reference not set to an instance of an object.

The following error gets logged in the K2 Configuration Service log when attempting to start the K2 Server service:

[Error] An error occurred using the connection to database '"K2"' on server '"%YOUR_SQL_SERVER_ALIAS%"'. System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Resolution

Starting from version 5.3, the K2 Server service has a dependency on the K2 Configuration Service (run in context of K2 Service account). This service is supposed to be running and should be able to connect to the K2 database, otherwise the K2 Server service will not be able to start.
Currently the K2 Configuration Service does not support using of the SQL alias where you have edited its appsettings.Production.json configuration file and replaced your SQL alias name with the real SQL server name (including instance name and port if necessary).

To resolve this issue you need to perform the following steps:

You can now just download updated 5.3 installer (5.0004.1000.2) where this problem does not occur. Workaround below can still be if you use old 5.3 installation package (5.0004.1000.1). More details about fixes included in updated 5.3 installer can be found in the K2 5.3 release notes under "Installer Resolved Items in K2 Five (5.3) (5.0004.1000.2)" section.

1. Edit appsettings.Production.json configuration file located in [INSTALL DIR]\SourceCode.Configuration.Api" and replace the SQL alias name with the SQL Server name in the K2ConnectionString as shown below:

Image

2. Restart the K2 Configuration Service

3. Start the K2 Server Service.