If the function succeeds, the return value is the current idle
timeout period in seconds. If the function fails, the return value
is LLM_ERROR. To get extended error information, call
LlmGetLastError.
The LlmGetIdleTime function returns the current idle timeout
period, in seconds, for the specified client session. This value
determines how long a connection can remain idle between requests
before the library automatically closes and re-establishes the
underlying HTTP connection.
Idle time is used to balance performance and reliability. Reusing
an existing connection can reduce overhead and improve performance,
particularly when multiple requests are made in quick succession.
However, connections that remain idle for extended periods may be
closed by the server or by intermediate network infrastructure. When
the idle time is exceeded, the library will proactively establish a
new connection before sending the next request.
This value is distinct from the timeout period and cache time.
The timeout period specifies how long the client will wait for a
response to a request before failing, while the cache time controls
how long certain responses or metadata may be reused without making
a new request. The idle time only affects how long an existing
connection is retained between requests.
The idle time can be modified using the LlmSetIdleTime
function. If a value of zero is specified, a new connection is
established for each request. In most cases, the default idle
time provides a good balance between performance and compatibility.
It is important to note that this setting only affects client-side
behavior. Increasing the idle time does not guarantee that a server
will keep the connection open for that duration. Many servers will
close idle connections after a shorter period of time, in which case
the library will automatically reconnect as needed.