<div dir="ltr">Never mind, I'm certain by now:<br><br><a href="http://sip-router.1086192.n5.nabble.com/DB-select-htable-mod-init-doesn-t-work-td127717.html">http://sip-router.1086192.n5.nabble.com/DB-select-htable-mod-init-doesn-t-work-td127717.html</a><br><a href="https://lists.kamailio.org/pipermail/sr-dev/2013-February/018484.html">https://lists.kamailio.org/pipermail/sr-dev/2013-February/018484.html</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 28 September 2017 at 22:18, George Diamantopoulos <span dir="ltr"><<a href="mailto:georgediam@gmail.com" target="_blank">georgediam@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Also, I' found this post by Daniel in 2014:<br><br><a href="https://lists.kamailio.org/pipermail/sr-users/2014-May/083155.html" target="_blank">https://lists.kamailio.org/<wbr>pipermail/sr-users/2014-May/<wbr>083155.html</a><br><br></div>To quote:<br>> Indeed, the db connection is not initialized at the time of executing <br>> event_route[htable:mod-init]. This is executed after all modules are <br>> initialized, but the sqlops connections are initialized in child init.<br><br></div>So maybe this is the case for 5.0.3 as well? sqlops functions can't be used in event_route[htable:mod-init] yet?<div><div class="h5"><br><div><div class="gmail_extra"><br><div class="gmail_quote">On 28 September 2017 at 20:18, George Diamantopoulos <span dir="ltr"><<a href="mailto:georgediam@gmail.com" target="_blank">georgediam@gmail.com</a>></span> wrote:<br><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"><div><div><span style="font-family:arial,helvetica,sans-serif">Hello,<br><br></span></div><span style="font-family:arial,helvetica,sans-serif">I've tested again, this time including a single sql_pvquery function in the event-route. Kamailio will also exit with "daemonize(): Main process exited before writing to pipe" in this simpler case.<br><br></span></div><span style="font-family:arial,helvetica,sans-serif">In the documentation, it is stated that: The event route is executed only
once, after core and module initialization, <emphasis>but before Kamailio forks any
child processes</emphasis>.
</span><pre class="m_-1256927168703043853gmail-m_1739572924155984834gmail-programlisting"><span style="font-family:arial,helvetica,sans-serif">Does this mean that I don't have (perhaps) access to pseudovariables during execution of this route? Is this the reason why kamailio exits prematurely?<br></span></pre><pre class="m_-1256927168703043853gmail-m_1739572924155984834gmail-programlisting"><span style="font-family:arial,helvetica,sans-serif">Thanks,<br></span></pre><pre class="m_-1256927168703043853gmail-m_1739572924155984834gmail-programlisting"><span style="font-family:arial,helvetica,sans-serif">George</span><br></pre></div><div class="m_-1256927168703043853gmail-HOEnZb"><div class="m_-1256927168703043853gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On 26 September 2017 at 15:37, George Diamantopoulos <span dir="ltr"><<a href="mailto:georgediam@gmail.com" target="_blank">georgediam@gmail.com</a>></span> wrote:<br><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">I forgot to mention, I'm using Kamailio 5.0.3 on debian "stretch".<br></div><div class="m_-1256927168703043853gmail-m_1739572924155984834HOEnZb"><div class="m_-1256927168703043853gmail-m_1739572924155984834h5"><div class="gmail_extra"><br><div class="gmail_quote">On 26 September 2017 at 14:40, George Diamantopoulos <span dir="ltr"><<a href="mailto:georgediam@gmail.com" target="_blank">georgediam@gmail.com</a>></span> wrote:<br><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"><div><div><div><div><div>Hello all,<br><br></div>I've been trying to utilise event_route[htable:mod-init] in order to load information from the database into an htable on startup. However, Kamailio exits with an error for no obvious (to me) reason. Here's the log output:<br><br><div style="margin-left:40px">DEBUG: htable [htable.c:226]: child_init(): rank is (-127)<br>DEBUG: htable [htable.c:259]: child_init(): executing event_route[htable:mod-init] (2)<br>DEBUG: <core> [core/parser/msg_parser.c:600]<wbr>: parse_msg(): SIP Request:<br>DEBUG: <core> [core/parser/msg_parser.c:602]<wbr>: parse_msg(): method: <OPTIONS><br>DEBUG: <core> [core/parser/msg_parser.c:604]<wbr>: parse_msg(): uri: <<a href="mailto:sip%3Ayou@kamailio.org" target="_blank">sip:you@kamailio.org</a>><br>DEBUG: <core> [core/parser/msg_parser.c:606]<wbr>: parse_msg(): version: <SIP/2.0><br>DEBUG: <core> [core/parser/parse_via.c:2639]<wbr>: parse_via(): end of header reached, state=2<br>DEBUG: <core> [core/parser/msg_parser.c:491]<wbr>: parse_headers(): Via found, flags=2<br>DEBUG: <core> [core/parser/msg_parser.c:493]<wbr>: parse_headers(): this is the first via<br>ERROR: <core> [core/daemonize.c:303]: daemonize(): Main process exited before writing to pipe<br></div><br></div>And here's the routing block in kamailio.cfg. What I need to do is get the username for all non-expired contacts in the "location" table, perform a query on another database for each one of them and store the result in an htable:</div><div><br><div style="margin-left:40px">event_route[htable:mod-init] {<br><br> sql_pvquery("ck", "select username from location where now() <= expires", "$avp(registered_ng)");<br><br> $var(i) = 0;<br> while ( $(avp(registered_ng)[$var(i)]) != $null ) {<br> sql_pvquery("ca", "select property from tablename where username = $(avp(registered_ng)[$var(i)])<wbr>", "$var(ng_property)");<br> $sht(isnguser=>$var(ng_propert<wbr>y)) = 1;<br> $var(i) = $var(i) + 1;<br> pv_unset("$var(ng_property)");<br> }<br><br> pv_unset("$var(i)");<br>}</div><br></div>Any hints as to what I might be doing wrong? Thanks!<br><br></div>Best regards,<br></div>George<br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div></div></div>
</blockquote></div><br></div>