There are a number of SQL connection strings used by K2 to make connections to the K2 database. And if you are using SmartBox or SQL Server SmartObjects, there are even more connection strings you will have to be aware of. When you encounter connection or timeout errors in K2, it is very important to know which connection strings you should look into.
When you are unable to start your K2 service, the first thing you should check is the HostServer logs. Usually the logs will provide important clues on why the service is unable to start.
Take note of the following error messages:
"K2 error connecting to database, will try in 30 seconds attempt 5"
"Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. This failure occurred while attempting to connect to the Principle server. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=15943; handshake=11422;"
You may experience other types of error as well, but If your K2 service is unable to start, and you see the following errors in the HostServer logs, then this is an indication that K2 is unable to connect to the K2 database. For the K2 service to be able to start, it must first connect to the K2 database.
For such a scenario, you will have to inspect the K2HostServer.exe.config. All connection strings in K2HostServer.exe.config are encrypted, so you will have to decrypt the connection strings before you can inspect them. You can follow the resolutions steps in this article to decrypt the K2HostServer.exe.config.
Once you have decrypted the connection strings, look for the uncommented <connectionStrings> section. You should see a number of connection strings to your K2 database.
Check if the connection strings are correct and working. Here are 2 methods to test the SQL connection:
Whichever method you use, we recommend you run the test with your K2 service account, on the K2 server.
If the connection string is wrong, you will need to update the connection strings in K2HostServer.exe.config.
If you have a connection timeout error, you can add a "Connection Timeout" property to your connection strings to extend the timeout. Here is an example how your connection string will look like with the "Connection Timeout property":
If you have updated your K2HostServer.exe.config, you will need to restart your K2 service for the changes to take effect.
This error message itself is not very useful. There are 2 common types of time out associated with SQL: Command timeout and connection timeout.
Connection timeout happens when K2 attempts to connect to the SQL database, but a time out is reached before the connection is established.
Command timeout happens when the connection has already been established, and a command or query has been sent to the SQL server. When the query fails to respond before a certain time, a command timeout error will occur. This is to manage resources and stop queries from running indefinitely.
You need to figure out what exactly "timed out".
When you see this error in Management, Workspace or Designer, check the HostServer logs and Event Viewer > Application logs for any timeout errors that occur at the same time you receive this error. The error and stack trace in these logs should give you a clue what type of timeout error you are facing.
If your K2 service is running, and you are getting connection timeout errors in Management, Workspace or Designer, then you have to check the SourceCode.Forms.Runtime.config.
There is an encrypted connection string in SourceCode.Forms.Runtime.config, so you will have to decrypt the config file before you can check the connection string. If you are facing connection timeout errors, you can add the "Connection Timeout" property to the connection string as well to extend the connection timeout.
Your browser is able to load K2 Management, but when you select certain sections from the menu on the left, you will receive a timeout error.
This is most likely a execution or command timeout error. In such case, you have to edit the K2HostServer.exe.config and look for the following lines:
<sourcecode.smartobjects.runtime smartObjectDependencyClassId="9812F4EA-75C9-48C1-83DB-578FCCE0CBC7" smartObjectServicesDependencyClassId="BB063376-0A7B-4849-BE59-49CDF511DC91" smartObjectServicesTypeDependencyClassId="EA60367A-5E41-4889-8F64-E1E494A77675" servicebrokerpath="C:\Program Files (x86)\K2\ServiceBroker" bufferrecords="20000" allowexponent="false" commandtimeout="30">
<execution commandTimeout="0.00:01:00" />
Update the commandtimeout value to a higher value, then save the changes and restart K2 service.
Only certain Form or View is throwing timeout error. Other forms are unaffected, and K2 Management, Workspace and Designer are all working properly.
First you need to know which timeout error you are getting. Is the error a connection timeout or command timeout?
Next you have to find out where the error is thrown from. Most of the time the error comes from a SmartObject execution.
There are 2 methods to check which SmartObject is throwing the error:
If a SmartObject is throwing the error, then you will have to inspect the Service Instance that the SmartObject is referencing. The Service Instance in turn references the another data source or service that you specified when creating the Service Instance.
As this article is only focusing on SQL related connection or timeout errors, this article is only going to be touching on the SQL Server Service and SmartBox Service.
Your SQL Server SmartObject stops working and is throwing connection errors or timeout errors. This can happen on either all SmartObjects referencing the same SQL Server Service Instance, or on only certain SmartObjects.
If you are using a SQL Server Service Instance, then you should notice there is a key called "Command Timeout" which is set to "30" by default:
If you are experiencing command timeout or execution timeout errors, then you have to increase the command timeout in your SQL Server Service Instance.
If it is a connection timeout error, then you add the connection timeout property in the Extra field:
If it is some other connection issue, you have to check if you are connecting to the correct SQL server and database, and check if the connection from your K2 server to your database is working properly. Take note of the Authentication Mode in the Service Instance as well, as this decides what account K2 will be using to connect to your database.
SmartBox SmartObjects are a special type of SmartObjects. When you create a SmartBox SmartObject, K2 creates a SQL table inside the K2 database. Any methods you execute from the SmartObject will query or update the records in the SQL table created in the K2 database.
There is only one service instance in use by all SmartBox SmartObject. If you face any issue with your SmartBox SmartObject, you should check the SmartBox Service Service Instance.
If the SmartObject throwing the timeout error is a SmartBox SmartObject, then you will need to edit the SmartBox Service Service Instance and update the sqlconnection.
The sqlconnection contains the connection string to the SmartBox database. This is masked on purpose, so you will need to check the K2 database to grab the connection string.
Please log a support case at Nintex Customer Central to request for support on retrieving this connection string. If need to, you can add additional properties such as "Connection Timeout" to the connection string to extend the connection timeout for SmartBox SmartObjects.
If you need further assistance in investigating your connection or timeout issue, please log a support case from Nintex Customer Central. When logging a support case, please try to provide the following details: