Since moving to the Web Client, have you seen this at all?
You probably have, and has it popped up while you were running a long processing routine? Yup, me too.
What’s Happening?
When you kick off those long running routines, your Web Client basically sits idle while the Service Tier is doing the processing. Once that idle time reaches a particular limit, the Service Tier shuts down that connection.
Changing the Timeout
When using the Windows Client it’s easy to set a few settings (see here) in the Service Tier configuration in order to adjust the session timeout for a user. Moving forward it remains just as easy, but if you’ve tried using the same settings as in the past, you’ve certainly noticed that they don’t work for the Web Client.
The session timeout for the Web Client is now controlled by settings in the Service Tier and in the Web Client configuration. I wish there was just a single setting, but maybe once the Windows Client is gone we’ll see some of the old settings go away as well.
In order to change the timeout for the Web Client, you need to change two settings. Thankfully though, we can easily change these settings using a couple of PowerShell commands.
ClientServicesIdleClientTimeout
This setting is found in the Microsoft Business Central Server configuration.
Set-NAVServerConfiguration DynamicsNAV130 -KeyName ClientServicesIdleClientTimeout -KeyValue "00:20:00"
The timeout uses this format: [dd.]hh:mm:ss[.ff]
dd – number of days
hh – number of hours
mm – number of minutes
ss – number of seconds
ff – hundredths of a second
Note
- You can also set the setting to “MaxValue” in order to indicate no timeout. This is also the default value for a new installation.
- You must restart the service tier for the new setting to take affect.
SessionTimeout
This settings is found in the navsettings.json file on the Microsoft Business Central Web Server.
Set-NAVWebServerInstanceConfiguration -WebServerInstance DynamicsNAV -KeyName SessionTimeout -KeyValue "00:20:00"
The timeout uses this format: [dd.]hh:mm:ss[.ff]
dd – number of days
hh – number of hours
mm – number of minutes
ss – number of seconds
ff – hundredths of a second
Note
- The default value is “00:20:00” (20 minutes) for a new installation.
How the Settings Work Together
The above settings are used in conjunction with each other. A session will be closed based on the setting that has the shortest time period.
By default, theĀ ClientServicesIdleClientTimeout setting is set to “MaxValue”, which means that in a default installation, theĀ SessionTimeout settings is what will be used.
This is also why configuring the Microsoft Business Central Server to a higher timeout does not work, since it is the setting that has the shortest time period that is used.
Summary
The ClientServicesIdleClientTimeout and SessionTimeout settings work together to determine the timeout of the Web Client. The setting that has the shortest time period is the one that is used to determine when a session is closed.
This means that in a default installation you can leave the ClientServicesIdleClientTimeout at its default value, and just change the SessionTimeout setting on the Microsoft Business Central Web Server to your desired timeout.
You can read more on this and other configurations you can set here.
Happy coding!
February 25, 2020 at 2:37 pm
Good article. How do I change SessionTimeout on a Docker container version of Business Central? I get this error with the command you gave:
Set-NAVWebServerInstanceConfiguration : The term ‘Set-NAVWebServerInstanceConfiguration’ is not recognized as the name
of a cmdlet, function, script file, or operable program.
November 17, 2020 at 11:50 am
You just need to wrap the original command within the BcContainerHelper Invoke-ScriptInBCContainer command, like this:
Invoke-ScriptInBCContainer -containerName myContainer -scriptblock {
Write-Host "Updating Web Client timeout"
Set-NAVWebServerInstanceConfiguration -WebServerInstance BC -KeyName SessionTimeout -KeyValue "12:00:00"
}