<div dir="ltr"><div dir="ltr">Thanks, Johan and Ben.<div><br></div><div>Johan:</div><div>I tried your suggested approach and (much to my surprise) it worked both for lua_exec and cache_remove_chunk. Thanks for that.<br></div><div><br></div><div>Ben:</div><div>I understand what you are saying for LUA. However, I think that if it's made clear that you do not have access to (or should not use) the message, the results should be predictable. It seems to work for me.</div><div><br></div><div>My LUA function is reading in external data and doesn't make use of the message at all. Perhaps there might be a way to provide an empty message to LUA if it's invoked in TIMER routes to avoid possible problems? LUA and Python offer powerful extendablity to OpenSIPS, so it seems to me to be a bit of a shame to limit their use at startup or in timers if all that's needed is a tweak - or even just a warning in the documentation.</div><div><br></div><div>As for the "cache_remove_chunk" - it's less clear why TIMER couldn't run this in a straightforward way as it's not dependent on the current message as far as I understand it.</div><div><br></div><div><br></div><div>If anybody wants to try doing this - here's an example that worked for me in OpenSIPS 3.1...</div><div><br></div></div><font face="monospace"> timer_route[refreshNodes, 30] {<br></font><font face="monospace"> route(remove_chunk);<br> route(cache_reload);<br></font><div><div><font face="monospace"> }</font></div></div><div dir="ltr"><div><br></div><div><font face="monospace"><br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> route[remove_chunk] {<br> cache_remove_chunk("validNodes", "*");<br> }<br><br> route[cache_reload] {<br> lua_exec("getValidNodes"); <br> for ($var(node) in $(avp(validNodes)[*])) {<br> cache_store("local:validNodes", "$var(node)", "true");<br> }<br> }</font><br></div><div><font face="monospace"><br></font></div><div><font face="monospace"><br></font></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 3 Dec 2020 at 14:20, Ben Newlin <<a href="mailto:Ben.Newlin@genesys.com">Ben.Newlin@genesys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="gmail-m_-4492233482406826912WordSection1">
<p class="MsoNormal">I wouldn’t recommend trying to bypass the restriction in this way. Both the lua and python exec modules were designed to operate on a SIP message, which is why they can only be called from routes that process messages. Calling it from time_route
where there is no message, even if you could get it to work, could have unexpected and unpleasant results.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">From LUA module doc for lua_exec: “Calls a Lua function with passing it the current SIP message” [1].<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">[1] <a href="https://opensips.org/docs/modules/3.1.x/lua.html#idp5933680" target="_blank">
https://opensips.org/docs/modules/3.1.x/lua.html#idp5933680</a><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><span style="color:black">Ben Newlin </span><u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">Users <<a href="mailto:users-bounces@lists.opensips.org" target="_blank">users-bounces@lists.opensips.org</a>> on behalf of Johan De Clercq <<a href="mailto:Johan@democon.be" target="_blank">Johan@democon.be</a>><br>
<b>Date: </b>Thursday, December 3, 2020 at 6:55 AM<br>
<b>To: </b>OpenSIPS users mailling list <<a href="mailto:users@lists.opensips.org" target="_blank">users@lists.opensips.org</a>><br>
<b>Subject: </b>Re: [OpenSIPS-Users] lua_exec in timer route - OpenSIPS 3.1<u></u><u></u></span></p>
</div>
<div>
<div>
<p class="MsoNormal">what you can try, is to call another route in the time route.
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">And then in that route, you execute the lua script. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">maybe (just a myabe) that will work. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">wkr, <u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">Op do 3 dec. 2020 om 12:23 schreef Mark Allen <<a href="mailto:mark@allenclan.co.uk" target="_blank">mark@allenclan.co.uk</a>>:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<p class="MsoNormal">Hi Johan<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">In the documentation for 3.1 lua module - TIMER_ROUTE is not one of the routes available to lua_exec. If I include it in a TIMER route, OpenSIPS fails to start with syntax error and the log error is:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"> CRITICAL:core:yyerror: parse error in /etc/opensips/opensips.cfg:265:19-20: Command <lua_exec> cannot be used in the block#012<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">If I move the lua_exec command into main route{ it works fine<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I also encounter the problem running a cache_remove_chunk in a TIMER route although the documentation doesn't say that it's not valid for TIMER route. It fails on startup with the error:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"> CRITICAL:core:yyerror: parse error in /etc/opensips/opensips.cfg:266:33-34: Command <cache_remove_chunk> cannot be used in the block#012<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Again - if I run the command in main route{ the command works fine<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">cheers,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Mark<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Thu, 3 Dec 2020 at 11:01, Johan De Clercq <<a href="mailto:Johan@democon.be" target="_blank">Johan@democon.be</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal">It for sure does not run in async mode. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Did you try executing a script in timer route ? <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">What's the output in the log ? <u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">Op do 3 dec. 2020 om 11:56 schreef Mark Allen <<a href="mailto:mark@allenclan.co.uk" target="_blank">mark@allenclan.co.uk</a>>:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<p class="MsoNormal">Is there a way to run a lua_exec from a timer route?<u></u><u></u></p>
</div>
<p class="MsoNormal">_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal">_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal">_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><u></u><u></u></p>
</blockquote>
</div>
</div>
</div>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</blockquote></div></div>