<p></p>

<h3>Description</h3>

<p>After upgrading kamailio from 5.4.4 to 5.4.5, the lcr module logs an error for outgoing calls. load_gws returns success (1), but does not populate the avps. Consequently, next_gw fails.</p>
<h3>Troubleshooting</h3>
<h4>Reproduction</h4>

<p>kamailio.cfg:</p>
<pre><code>loadmodule "lcr.so"

...

modparam("lcr", "db_url", "cluster://cls1")
modparam("lcr", "gw_uri_avp", "$avp(i:709)")
modparam("lcr", "ruri_user_avp", "$avp(i:500)")
modparam("lcr", "tag_avp", "$avp(lcr_tag)")
modparam("lcr", "flags_avp", "$avp(i:712)")
modparam("lcr", "defunct_capability", 1)
modparam("lcr", "lcr_id_avp", "$avp(s:lcr_id_avp)")
modparam("lcr", "defunct_gw_avp", "$avp(s:defunct_gw_avp)")
modparam("lcr", "ping_interval", 60)

...

route[LCR] {
        if(!($rU=~"^[+0-9]"))
                return;

        if(is_method("INVITE")) {
                if (!($fU=~"^[+0-9]+$")) {
                        append_hf("P-Asserted-Identity: <sip:+49xxxxxxxxxxx@xxxxx.de>\n");
                        append_hf("Privacy: id\n");
                        $fn = "Anonymous";
                        $fu = "sip:+49xxxxxxxxxxx@xxxxx.de";
                }

                if(load_gws(1, $rU, $var(caller_uri)) != 1) {
                        xlog("L_ERROR", "Couldn't load gateways\n");
                        sl_send_reply("500", "Server Internal Error - Cannot load gateways");
                        exit;
                } else {
                        xlog("L_INFO", "GW Selected '$avp(i:709)'\n");
                        xlog("L_INFO", "Domain of destination: $dd\n");
                        xlog("L_INFO", "To URI: $tu\n");
                }

                if(!next_gw()) {
                        xlog("L_WARN", "No gateway configured for $rU\n");
                        sl_send_reply("503", "Service not available, no gateways found");
                        exit;
                } else {
                        xlog("L_INFO", "Calling the first matched gateway\n");
                        xlog("L_INFO", "ruri_user_avp: '$avp(i:500)'\n");
                        xlog("L_INFO", "To URI after next_gw: $tu\n");
                        xlog("L_INFO", "Request URI: $ru\n");
                }

                t_on_failure("MANAGE_FAILURE_LCR");
                route(RELAY);
                exit;
        }
}
</code></pre>
<h4>Debugging Data</h4>

<h4>Log Messages</h4>

<pre><code>Apr 15 20:59:27 x /usr/sbin/kamailio[879]: ERROR: <core> [core/usr_avp.c:152]: create_avp(): 0 ID or NULL NAME AVP!
Apr 15 20:59:27 x /usr/sbin/kamailio[879]: ERROR: <core> [core/usr_avp.c:152]: create_avp(): 0 ID or NULL NAME AVP!
Apr 15 20:59:27 x /usr/sbin/kamailio[879]: INFO: <script>: GW Selected '<null>'
Apr 15 20:59:27 x /usr/sbin/kamailio[879]: INFO: <script>: Domain of destination: <null>
Apr 15 20:59:27 x /usr/sbin/kamailio[879]: INFO: <script>: To URI: sip:+49177xxxxxxx@xx.xxx.x.xxx:5060
Apr 15 20:59:27 x /usr/sbin/kamailio[879]: WARNING: <script>: No gateway configured for +49177xxxxxxx
</code></pre>
<h4>SIP Traffic</h4>

<p>SIP request:</p>
<pre><code>        INVITE sip:+49177xxxxxxx@xx.xx.xx.xxx:5060 SIP/2.0
        Via: SIP/2.0/UDP xxx.xx.xx.xxx:xxxxx;branch=z9hG4bK5d833a50
        Max-Forwards: 70
        From: <sip:+xxxxxxxxxxx@xxx.xx.xx.xxx:xxxxx>;tag=as18ff0d47
        To: <sip:+49177xxxxxxx@xx.xx.xx.xxx:5060>
        Contact: <sip:+xxxxxxxxxxx@xxx.xx.xx.xxx:xxxxx>
        Call-ID: 7489c50703b43b2f03980574181a2f81@xxx.xx.xx.xxx:xxxxx
        CSeq: 102 INVITE
        User-Agent: Asterisk PBX 13.18.3~dfsg-1ubuntu4
        Date: Thu, 15 Apr 2021 21:52:42 GMT
        Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
        Supported: replaces, timer
        Content-Type: application/sdp
        Content-Length: 952

...
</code></pre>
<p>SIP reply:</p>
<pre><code>        SIP/2.0 503 Service not available, no gateways found
        Via: SIP/2.0/UDP xxx.xx.xx.xxx:xxxxx;branch=z9hG4bK5d833a50;rport=50060;received=xx.xx.xx.xxx
        From: <sip:+xxxxxxxxxxx@xxx.xx.xx.xxx:xxxxx>;tag=as18ff0d47
        To: <sip:+49177xxxxxxx@xx.xx.xx.xxx:5060>;tag=6a823999ce344a0b461cf8d85d526103.51611a36
        Call-ID: 7489c50703b43b2f03980574181a2f81@xxx.xx.xx.xxx:xxxxx
        CSeq: 102 INVITE
        Server: kamailio (5.4.5 (x86_64/linux))
        Content-Length: 0
</code></pre>
<h3>Possible Solutions</h3>

<p>As a workaround, I downgraded to kamailio 5.3.8 because the previous Ubuntu release 5.4.4 is not available anymore at <a href="http://deb.kamailio.org/kamailio54/pool/main/k/kamailio/" rel="nofollow">http://deb.kamailio.org/kamailio54/pool/main/k/kamailio/</a> (why actually?)</p>
<h3>Additional Information</h3>
<ul>
<li><strong>Kamailio Version</strong> 5.4.5</li>
<li><strong>Operating System</strong>: Ubuntu 18.04</li>
</ul>

<h3>Root Cause Assumption</h3>
<p><a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/kamailio/kamailio/commit/ca1821837dfe7dd6630f628d968ed4d1178c7040/hovercard" href="https://github.com/kamailio/kamailio/commit/ca1821837dfe7dd6630f628d968ed4d1178c7040"><tt>ca18218</tt></a> might be involved in the issue.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/2709">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZII2EPSTSV7FOLRATLTI54GDANCNFSM43AORSHA">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABO7UZPLWKNBPTFRLZ45YM3TI54GDA5CNFSM43AORSHKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4MZYNZ7Q.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/2709",
"url": "https://github.com/kamailio/kamailio/issues/2709",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>