Skip to content

Latest commit

 

History

History
107 lines (65 loc) · 13.9 KB

understanding-session-timeouts.md

File metadata and controls

107 lines (65 loc) · 13.9 KB
title description ms.date ms.topic author
Configure Session Timeout
When you start a Business Central client, a connection is established, and a corresponding session is added to the Business Central Server.
04/01/2021
conceptual
jswymer

Session Timeout Settings and Configuration

When you start a client, such as connecting to [!INCLUDE prod_short] in a browser, a connection is established with the [!INCLUDEserver] instance and a corresponding session is added on [!INCLUDEserver].

[!INCLUDEserver] includes several timeout settings that determine when a session closes as a result of inactivity over the client connection, lost client connection, or closing of the client. To help you configure the timeout settings, this document provides an overview of how the session timeouts work and answers some basic questions about session behavior.

Session timeout settings overview

This section provides an overview of the settings that are available in [!INCLUDEprod_short] to control when a [!INCLUDEserver] session for a [!INCLUDEprod_short] client connection times out and closes. Some of the settings are set on [!INCLUDEserver] and others are set for the [!INCLUDEnav_web]. For more details about using these settings, see the other sections in this topic.

[!INCLUDEserver] timeout settings

The following table describes the session timeout settings that are used by [!INCLUDEserver].

Setting Description Remarks
ClientServicesReconnectPeriod The amount of time during which a client can reconnect to an existing session on [!INCLUDEserver] before a session closes. For more information, see Configuring How Long a Session Remains Open after the Client Connection is Lost.
ClientServicesIdleClientTimeout The interval of time that a [!INCLUDEprod_short] client connection can remain inactive before the session is closed. For more information, see Configuring How Long a Session Remains Open When the Client Connection is Inactive.

These settings are available in the CustomSettings.config file of [!INCLUDEserver]. For more information about this file, see Configuring Business Central Server.

[!INCLUDEnav_web] timeout settings

The following table describes the session timeout settings that are used by the [!INCLUDEnav_web].

Setting Description Remarks
SessionTimeout Specifies the amount of time that session remains open when there is no activity over the connection from the [!INCLUDEnav_web] to [!INCLUDEserver]. For more information, see Configuring Business Central Server.

This setting is available in the navsettings.json configuration file of the [!INCLUDEwebserver.md]. For more information about this file, see Configuring Web Server.

Configuring How Long a Session Remains Open When the Client Connection is Inactive

Inactivity on a connection is when the [!INCLUDEprod_short] client is not sending messages to [!INCLUDEserver].

Configuring the inactive session timeout for the [!INCLUDEnav_web]

There are two settings that control when a Web client session closes because of inactivity on a connection:

  • ClientServicesIdleClientTimeout setting on [!INCLUDEserver].

  • SessionTimeout setting on the [!INCLUDEprod_short] Web Server.

The session closes according to the setting that has the shortest time period. By default, the ClientServicesIdleClientTimeout setting is set to MaxValue, which means no time limit, and the SessionTimeout setting is 00:20:00 (20 minutes). This means that when client connection is inactive, a session will close after 20 minutes. The following figure illustrates the timeout behavior:

Inactivity session timeout.

Configuring How Long a Session Remains Open after the Client Connection is Lost

Occasionally, a [!INCLUDEprod_short] client can lose the network connection to [!INCLUDEserver]. You can use ClientServicesReconnectPeriod setting on [!INCLUDEserver] to control how long a session remains open after the connection is lost to allow time for the client to reconnect to the session.

The time a session remains open actually depends two settings: ClientServicesKeepAliveInterval and ClientServicesReconnectPeriod. The ClientServicesKeepAliveInterval setting is used to specify an initial inactivity period. The initial inactivity period is equal to two times the ClientServicesKeepAliveInterval setting value. After this initial inactivity period, the session remains open for the time period that is specified ClientServicesReconnectPeriod setting. By default, the ClientServicesKeepAliveInterval setting is 120 seconds (2 minutes) and the ClientServicesReconnectPeriod setting is 10 minutes. This means that [!INCLUDEserver] waits approximately 14 minutes for the client to reconnect before closing the session.

The following figure illustrates the reconnect session timeout behavior.

Reconnect session timeout.

The process that occurs when a client does not reconnect to the session is explained as follows:

  1. The connection is lost and the initial inactivity period starts (default is 4 minutes).

  2. After the initial inactivity period, the service channel enters a faulted state.

    When the service channel is in the faulted state, [!INCLUDEserver] considers the session with the client as orphaned and waits for it to reconnect.

  3. If the client does not reconnect within the time period that is specified by the ClientServicesReconnectPeriod setting (default is 10 minutes), then [!INCLUDEserver] closes the session.

  4. The session is then removed from the Active Session table in the [!INCLUDEprod_short].

FAQ

This section answers some typical questions about session timeout.

What happens to the session if the client loses the connection to [!INCLUDEserver]?

By default, it will take approximately 14 minutes for the [!INCLUDEserver] to close the current session. The time it takes to close the session is in part determined by the ClientServicesReconnectPeriod setting on [!INCLUDEserver] plus an initial 10 minute inactivity period. For more information, see Configuring How Long a Session Remains Open after the Client Connection is Lost.

What happens if the session is still active when [!INCLUDEserver] tries to close it?

  1. The server stops any executing threads when the next statement is to be executed and the current call stack is aborted so any uncommitted transactions will be rolled back.

  2. The server cancels any callbacks to the client (similar to waiting for the response to a Confirm dialog).

  3. The session is closed, and then removed from the Active Session table.