Investigating SQL Connection Or Timeout Errors in K2 Five

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.

 

Scenarios

 

Unable to start K2 service, connection errors are thrown

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.

 

What to check

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.

 

decrypted_connstr.png

 

Check if the connection strings are correct and working. Here are 2 methods to test the SQL connection:

  1. Create a PowerShell script and use the same connection string to test a connection to your K2 database. Run the script on your K2 server.
  2. Create a .UDL file on the K2 server, and use that to test the 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":

 

add_conn_timeout_1.png

 

If you have updated your K2HostServer.exe.config, you will need to restart your K2 service for the changes to take effect.

 

K2 service is running, but you see a wait operation timed out error when opening Management, Designer or Workspace

wait_operation_timed_out.png

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".

 

What to check

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.

 

add_conn_timeout_2.png

 

Timeout errors thrown when opening certain sections in K2 Management

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.

 

What to check

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.

 

Specific Form or View is throwing timeout errors

Only certain Form or View is throwing timeout error. Other forms are unaffected, and K2 Management, Workspace and Designer are all working properly.

 

What to check

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:

  1. Enable SmartObject logging, then check the SmartObject logs to see which SmartObject is throwing the timeout error.
  2. Record a network trace, then look for the http request that returns the error in the response. You can refer to this article on how to do this.

 

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.

 

SQL Server SmartObject is throwing connection or timeout errors

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.

 

What to check

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:

 

sql_service_instance.png

 

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:

 

sql_service_conn_timeout.png

 

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 SmartObject is throwing connection or timeout errors

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.

 

What to check

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.

 

smartbox_service.png

 

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.

 

Additional Information

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:

 

  • Where is the error thrown from
  • How many Forms, Views or SmartObjects are having this error
  • Screenshot of the Service Instance settings
  • HostServer logs from when the issue occur
  • SmartObject logs if your error is coming from SmartObjects
  • Network trace from either your browser developer tool or Fiddler if you do not know where in your Form or View the error is coming from
Labels: (1)
Version history
Revision #:
14 of 14
Last update:
3 weeks ago
Updated by:
 
Contributors