<div dir="ltr">Your right Johan! :-D<div><br></div><div>For info  - I do see an error in the log...</div><div><br></div>TIMER_ROUTE: get data<br>ERROR:core:parse_from_header: bad msg or missing FROM header<br>ERROR:core:pv_get_from_attr: cannot parse From header<br>Message info: <null>, <null>, <null>, DUMMY<br><div><br></div><div>...where "Message info" comes from: xlog("Message info: $fU, $tU, $td, $rm");</div><div><br></div><div>However, I've had multiple timers kicking off LUA scripts all running for a while now and I've not seen any problems. YMMV</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 23 Dec 2020 at 15:17, johan <<a href="mailto:johan@democon.be">johan@democon.be</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>
    <p>then you are fine :-)<br>
    </p>
    <div>On 4/12/2020 09:26, Mark Allen wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div dir="ltr">Interestingly - TIMER already seems to use some
          form of dummy message to avoid problems. If I add the line...
          <div><br>
          </div>
          <div><font face="monospace">    timer_route[checkNodeCache, 5]
              {<br>
                      xlog("TIMER_ROUTE");<br>
                      xlog("Message info: $fU, $tU, $td, $rm");</font><br>
          </div>
          <div><br>
          </div>
          <div>...what is logged is...</div>
          <div><br>
          </div>
          <div><font face="monospace">    Message info: <null>,
              <null>, <null>, DUMMY<br>
            </font></div>
          <div><br>
          </div>
        </div>
        <div>...so LUA will be passed a (very simple) message it seems</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div class="gmail_quote">
          <div dir="ltr" class="gmail_attr">On Thu, 3 Dec 2020 at 15:57,
            Mark Allen <<a href="mailto:mark@allenclan.co.uk" target="_blank">mark@allenclan.co.uk</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 dir="ltr">LOL! Yes, I did understand, but it is an
              important distinction.</div>
            <br>
            <div class="gmail_quote">
              <div dir="ltr" class="gmail_attr">On Thu, 3 Dec 2020 at
                15:53, Ben Newlin <<a href="mailto:Ben.Newlin@genesys.com" target="_blank">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">
                  <div>
                    <p class="MsoNormal">It seems like you read that as
                      I intended, but I want to clarify I meant to say I
                      <i>wouldn’t</i> feel safe assuming that this would
                      work long term.</p>
                    <p class="MsoNormal"> </p>
                    <p class="MsoNormal"><span style="color:black">Ben
                        Newlin </span></p>
                    <p class="MsoNormal"> </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 Mark Allen <<a href="mailto:mark@allenclan.co.uk" target="_blank">mark@allenclan.co.uk</a>><br>
                          <b>Date: </b>Thursday, December 3, 2020 at
                          10:40 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</span></p>
                    </div>
                    <div>
                      <div>
                        <p class="MsoNormal">> a memory leak or
                          segfault after continued use</p>
                      </div>
                      <div>
                        <p class="MsoNormal"> </p>
                      </div>
                      <div>
                        <p class="MsoNormal">Yes - it would be useful to
                          know if this could result in problems down the
                          road. Not sure how else I can run a timed job
                          if I can't use the TIMER route though.</p>
                      </div>
                      <p class="MsoNormal"> </p>
                      <div>
                        <div>
                          <p class="MsoNormal">On Thu, 3 Dec 2020 at
                            15:17, Ben Newlin <<a href="mailto:Ben.Newlin@genesys.com" target="_blank">Ben.Newlin@genesys.com</a>>
                            wrote:</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">Mark,</p>
                              <p class="MsoNormal"> </p>
                              <p class="MsoNormal">My concern was less
                                about you using the message object in
                                LUA as it was with how robust OpenSIPS’
                                handling is if a message if expected to
                                be there and memory is allocated and
                                passed but there is no actual message
                                due to this “trick”. Without digging
                                into the actual code, I would feel safe
                                assuming that this wouldn’t result in a
                                memory leak or segfault after continued
                                use.</p>
                              <p class="MsoNormal"> </p>
                              <p class="MsoNormal"><span style="color:black">Ben Newlin
                                </span></p>
                              <p class="MsoNormal"> </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 Mark Allen <<a href="mailto:mark@allenclan.co.uk" target="_blank">mark@allenclan.co.uk</a>><br>
                                    <b>Date: </b>Thursday, December 3,
                                    2020 at 10:04 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</span></p>
                              </div>
                              <div>
                                <div>
                                  <p class="MsoNormal">Thanks, Johan and
                                    Ben.</p>
                                  <div>
                                    <p class="MsoNormal"> </p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal">Johan:</p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal">I tried your
                                      suggested approach and (much to my
                                      surprise) it worked both for
                                      lua_exec and cache_remove_chunk.
                                      Thanks for that.</p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal"> </p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal">Ben:</p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal">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.</p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal"> </p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal">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.</p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal"> </p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal">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.</p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal"> </p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal"> </p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal">If anybody
                                      wants to try doing this - here's
                                      an example that worked for me in
                                      OpenSIPS 3.1...</p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal"> </p>
                                  </div>
                                </div>
                                <p class="MsoNormal"><span>   
                                    timer_route[refreshNodes, 30] {<br>
                                            route(remove_chunk);<br>
                                            route(cache_reload);</span></p>
                                <div>
                                  <div>
                                    <p class="MsoNormal"><span>    }</span></p>
                                  </div>
                                </div>
                                <div>
                                  <div>
                                    <p class="MsoNormal"> </p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal"> </p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal"> </p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal"><span>   
                                        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>
                                            }</span></p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal"> </p>
                                  </div>
                                  <div>
                                    <p class="MsoNormal"> </p>
                                  </div>
                                </div>
                                <p class="MsoNormal"> </p>
                                <div>
                                  <div>
                                    <p class="MsoNormal">On Thu, 3 Dec
                                      2020 at 14:20, Ben Newlin <<a href="mailto:Ben.Newlin@genesys.com" target="_blank">Ben.Newlin@genesys.com</a>>
                                      wrote:</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:5pt 0in 5pt 4.8pt">
                                    <div>
                                      <div>
                                        <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.</p>
                                        <p class="MsoNormal"> </p>
                                        <p class="MsoNormal">From LUA
                                          module doc for lua_exec:
                                          “Calls a Lua function with
                                          passing it the current SIP
                                          message” [1].</p>
                                        <p class="MsoNormal"> </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></p>
                                        <p class="MsoNormal"> </p>
                                        <div>
                                          <p class="MsoNormal"><span style="color:black">Ben
                                              Newlin
                                            </span></p>
                                        </div>
                                        <p class="MsoNormal"> </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</span></p>
                                        </div>
                                        <div>
                                          <div>
                                            <p class="MsoNormal">what
                                              you can try, is to call
                                              another route in the time
                                              route.
                                            </p>
                                          </div>
                                          <div>
                                            <p class="MsoNormal">And
                                              then in that route, you
                                              execute the lua script.
                                            </p>
                                          </div>
                                          <div>
                                            <p class="MsoNormal">maybe
                                              (just a myabe) that will
                                              work.
                                            </p>
                                          </div>
                                          <div>
                                            <p class="MsoNormal"> </p>
                                          </div>
                                          <div>
                                            <p class="MsoNormal">wkr,
                                            </p>
                                          </div>
                                        </div>
                                        <p class="MsoNormal"> </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>>:</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:5pt 0in 5pt 4.8pt">
                                            <div>
                                              <p class="MsoNormal">Hi
                                                Johan</p>
                                              <div>
                                                <p class="MsoNormal"> </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:</p>
                                              </div>
                                              <div>
                                                <p class="MsoNormal"> </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</p>
                                              </div>
                                              <div>
                                                <p class="MsoNormal"> </p>
                                              </div>
                                              <div>
                                                <p class="MsoNormal">If
                                                  I move the lua_exec
                                                  command into main
                                                  route{ it works fine</p>
                                              </div>
                                              <div>
                                                <p class="MsoNormal"> </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:</p>
                                              </div>
                                              <div>
                                                <p class="MsoNormal"> </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</p>
                                              </div>
                                              <div>
                                                <p class="MsoNormal"> </p>
                                              </div>
                                              <div>
                                                <p class="MsoNormal">Again
                                                  - if I run the command
                                                  in main route{ the
                                                  command works fine</p>
                                              </div>
                                              <div>
                                                <p class="MsoNormal"> </p>
                                              </div>
                                              <div>
                                                <p class="MsoNormal"> </p>
                                              </div>
                                              <div>
                                                <p class="MsoNormal">cheers,</p>
                                              </div>
                                              <div>
                                                <p class="MsoNormal"> </p>
                                              </div>
                                              <div>
                                                <p class="MsoNormal">Mark</p>
                                              </div>
                                            </div>
                                            <p class="MsoNormal"> </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:</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:5pt 0in 5pt 4.8pt">
                                                <div>
                                                  <div>
                                                    <p class="MsoNormal">It
                                                      for sure does not
                                                      run in async mode.
                                                    </p>
                                                  </div>
                                                  <div>
                                                    <p class="MsoNormal">Did
                                                      you try executing
                                                      a script in timer
                                                      route ?
                                                    </p>
                                                  </div>
                                                  <div>
                                                    <p class="MsoNormal">What's
                                                      the output in the
                                                      log ?
                                                    </p>
                                                  </div>
                                                </div>
                                                <p class="MsoNormal"> </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>>:</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:5pt 0in 5pt 4.8pt">
                                                    <div>
                                                      <p class="MsoNormal">Is
                                                        there a way to
                                                        run a lua_exec
                                                        from a timer
                                                        route?</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></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></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></p>
                                          </blockquote>
                                        </div>
                                      </div>
                                    </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></p>
                                  </blockquote>
                                </div>
                              </div>
                            </div>
                          </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></p>
                        </blockquote>
                      </div>
                    </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>
          </blockquote>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <pre>_______________________________________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
  </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>