Tryton 7 Session Expiration Issue

I am using GNU Health 5.0 with Tryton 7. I have configured the session to expire after 3 minutes of inactivity. However, the session expiration is not working consistently.

In some cases, I receive a Gateway Error, while in other cases, when I am actively working in the system, it unexpectedly asks me to enter my password again.

Could you please help me identify the cause of this issue and advise how to properly configure the Tryton session timeout so that it works consistently without causing Gateway Errors or unexpected password prompts?

When the system asks your password again means that the session has expiered. So it seems the session is expiration is working.

The gateway error probably is because you have a proxy in front of tryton and the proxy is unable to contact the server.

That’s what I can see with your setup. Unless you share more details about your setups and logs of the errors we can not provide more help.

Also It will be great what you want to achieve with the 3 minutes timeout.

If you are talking about the configuration [session] timeout is about the freshness of the session. This is checked only for specific actions. So this can be the reason for your un-expectation.

Now if you have setup [session] max_age then you must adapt [session] timeout to be lower in order to have effect.

Also remember that the freshness of a session is based on the requests performed to the server. If the client is “used” but does not trigger any server request, these actions are not refreshing the session.

Session refresh time is 10 minutes, so it ask password after 10 minutes .
I want to configure the system so that if a user remains idle for 10 minutes, the session should expire or require the user to enter their password again.

The password prompt should occur only after 10 minutes of inactivity and should not interrupt users while they are actively working in the system.

To achieve that you must modify all the RPC definitions to set fresh_session to True and set [session] timeout to 10min.
By default Tryton set it only for important operation like posting an invoice or approve a payment.

You can achieve that by registering a mixin on the Model, Wizard and Report classes.

Something like this (untested code):

from trytond.model import Model
from trytond.wizard import Wizard
from trytond.report import Report
from trytond.pool import Pool


class FreshSessionMixin:
    __slots__ = ()

    @classmethod
    def __setup__(cls):
        super().__setup__()
        for rpc in cls.__rpc__.values():
            rpc.fresh_session = True


def register():
    Pool.register_mixin(
        FreshSessionMixin, Model, module='yourmodule')
    Pool.register_mixin(
        FreshSessionMixin, Wizard, module='yourmodule')
    Pool.register_mixin(
        FreshSessionMixin, Report, module='yourmodule')