From abalashov@evaristesys.com Wed Nov 29 21:34:52 2023 From: Alex Balashov To: sr-users@lists.kamailio.org Subject: [SR-Users] Re: No access to variables within timer route Date: Wed, 29 Nov 2023 16:34:28 -0500 Message-ID: <3BDD4FA6-2B1B-40E5-8E53-B86E9C828680@evaristesys.com> In-Reply-To: <170129176081.1570.7772619828783390214@main.kamailio.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0702858376==" --===============0702858376== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi, It is important to know that the scope of $var(...) is per-process[1], and ti= mer functions run in a different process.=20 When REFRESH_CALLSTATE_TIMER runs, it is not in response to any particular SI= P message or call, and it does not know the context of any particular SIP mes= sage or call.=20 -- Alex [1] Which also has unexpected consequences when a different SIP message hits = the same process in which a $var() was set before; they are process-persisten= t, as the documentation notes. > On 29 Nov 2023, at 16:02, dries--- via sr-users wrote: >=20 > Hi, >=20 > I have a timer which is called each 5 seconds: > modparam("timer", "declare_timer", "REFRESH_CALLSTATE_TIMER=3DREFRESH_CALLS= TATE_TIMER,5000,slow"); >=20 > I'm enabling setting the variable "testvar" and enabling the timer when an = INVITE is received: > if (is_method("INVITE|ACK|UPDATE|CANCEL|BYE")) { > $var(testvar) =3D "blablabla"; > timer_enable("REFRESH_CALLSTATE_TIMER", "1"); > ... >=20 > route[REFRESH_CALLSTATE_TIMER] { > xlog("L_INFO", "Testvariable: $var(test)\n"); > } >=20 > However, the variable is always 0: > INFO: