<p></p>
<h3>Description</h3>
<p>In following configuration :</p>
<p>UA -> KAMALIO PROXY -> REGISTRAR</p>
<p>In case if REGISTRAR answer 404 on first REGISTER kamailio just ignore it and reply not passed to onreply_route. ie 404 just dropped and not passed to UA.<br>
In case if REGISTRAR answer 401 on first REGISTER kamailio works like it have to be.</p>
<p>Grepped example :</p>
<pre><code>77.77.77.77 - UA
88.88.88.88 - Kamailio
10.34.64.2 - registrar

U 2020/04/02 10:47:02.345372 77.77.77.77:5060 -> 88.88.88.88:7060 #26887
REGISTER sip:proxy.domain.com:7060 SIP/2.0.
Via: SIP/2.0/UDP 10.32.0.9:5060;branch=z9hG4bK4153798595.
From: "999100044" <sip:999100044@proxy.domain.com:7060>;tag=3123330837.
To: "999100044" <sip:999100044@proxy.domain.com:7060>.
Call-ID: 2_912627073@10.32.0.9.
CSeq: 1 REGISTER.
Contact: <sip:999100044@10.32.0.9:5060>.
Allow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE.
Max-Forwards: 70.
User-Agent: Yealink SIP-T46G 28.81.188.7 001565b577b2.
Expires: 3600.
Allow-Events: talk,hold,conference,refer,check-sync.
Content-Length: 0.
..


U 2020/04/02 10:47:04.289850 88.88.88.88:7060 -> 10.34.64.2:5060 #26888
REGISTER sip:proxy.domain.com:7060 SIP/2.0.
Record-Route: <sip:88.88.88.88:7060;lr>.
Via: SIP/2.0/UDP 88.88.88.88:7060;branch=z9hG4bK0636.d927d7e86ebc02302d9ad6ae7d778817.0.
Via: SIP/2.0/UDP 10.32.0.9:5060;received=77.77.77.77;branch=z9hG4bK4153798595.
From: "999100044" <sip:999100044@proxy.domain.com:7060>;tag=3123330837.
To: "999100044" <sip:999100044@proxy.domain.com:7060>.
Call-ID: 2_912627073@10.32.0.9.
CSeq: 1 REGISTER.
Contact: <sip:999100044@10.32.0.9:5060>.
Allow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE.
Max-Forwards: 69.
User-Agent: Yealink SIP-T46G 28.81.188.7 001565b577b2.
Expires: 3600.
Allow-Events: talk,hold,conference,refer,check-sync.
Content-Length: 0.
Path: <sip:88.88.88.88:7060;lr;received=sip:77.77.77.77:5060>.
Supported: path.
..


U 2020/04/02 10:47:04.290295 10.34.64.2:5060 -> 88.88.88.88:7060 #26889
SIP/2.0 404 Not Found.
Via: SIP/2.0/UDP 88.88.88.88:7060;branch=z9hG4bK0636.d927d7e86ebc02302d9ad6ae7d778817.0.
Via: SIP/2.0/UDP 10.32.0.9:5060;received=77.77.77.77;branch=z9hG4bK4153798595.
From: "999100044" <sip:999100044@proxy.domain.com:7060>;tag=3123330837.
To: "999100044" <sip:999100044@proxy.domain.com:7060>;tag=1598650872.
Call-ID: 2_912627073@10.32.0.9.
CSeq: 1 REGISTER.
Content-Length: 0.
Date: Thu, 02 Apr 2020 10:47:03 GMT.
Warning: Not maintaining bindings for domain.
..
</code></pre>
<h3>Troubleshooting</h3>
<p>After checking RFC 3261 i found that</p>
<pre><code> 5. The registrar extracts the address-of-record from the To header
         field of the request.  If the address-of-record is not valid
         for the domain in the Request-URI, the registrar MUST send a
         404 (Not Found) response and skip the remaining steps. 
</code></pre>
<h4>Reproduction</h4>
<p>following schema :<br>
UA -> KAMALIO PROXY -> REGISTRAR</p>
<p>modules  related to issue:<br>
in kamailio.cfg</p>
<p>loadmodule "tm.so"<br>
loadmodule "tmx.so"<br>
loadmodule "sl.so"<br>
loadmodule "rr.so"<br>
loadmodule "db_mysql"<br>
loadmodule "domain"<br>
loadmodule "outbound"<br>
loadmodule "path"</p>
<p>simple conception route config which illustrate issue :</p>
<pre><code>request_route 
{

        # per request initial checks
        route(REQINIT);

        route(CATCH_CANCEL);

        route(RR_PARSE);

        route(REGISTRATION);

        xlog("L_INFO", "Initial relay packet\n");
        $du = "sip:10.34.64.2:5060";

        route(FORWARD);

        # update $du to set the destination address for proxying
        exit;
}

route[CATCH_CANCEL]
{
    if (is_method("CANCEL") == true)
    {
        if (t_check_trans() == true)
        {
            route(FORWARD);
        }
        sl_reply("500", "Internal Server Error");
        drop;
    }
}


route[RR_PARSE]
{
    if(loose_route() == true )
    {
        xlog("L_INFO", "RR-enforced\n");
        append_hf("P-hint: rr-enforced\r\n"); 
        route(FORWARD);

    } else 
        {
            xlog("L_INFO", "RR simple\n");
            record_route();
        }
}

route[REGISTRATION]
{
    if(is_method("REGISTER") == true)
    {
        add_path_received();
        append_hf("Supported: path\r\n");
        xlog("L_INFO", "GOT REGISTER\n");
    }
}

route[FORWARD]
{
    if(t_relay() == false)
    {
        sl_reply_error();
    }
    
    drop;
}


onreply_route
{
    xlog("Reply SIP message from $si:$sp\n");
    if (t_check_trans() == false)
    {
        drop;
    }
}
</code></pre>
<h4>Debugging Data</h4>
<h4>Log Messages</h4>
<pre><code>Apr  2 11:05:26 fsinnosbc /usr/sbin/kamailio[16037]: INFO: {1 1 REGISTER 2_1386563412@10.32.0.9} <script>: RR simple
Apr  2 11:05:26 fsinnosbc /usr/sbin/kamailio[16037]: INFO: {1 1 REGISTER 2_1386563412@10.32.0.9} <script>: GOT REGISTER
Apr  2 11:05:26 fsinnosbc /usr/sbin/kamailio[16037]: INFO: {1 1 REGISTER 2_1386563412@10.32.0.9} <script>: Initial relay packet
</code></pre>
<h4>SIP Traffic</h4>

<pre><code>(paste your sip traffic here)
</code></pre>
<h3>Possible Solutions</h3>

<h3>Additional Information</h3>
<ul>
<li><strong>Kamailio Version</strong> - output of <code>kamailio -v</code></li>
</ul>
<pre><code>version: kamailio 5.3.3 (x86_64/linux) 
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown 
compiled with gcc 8.3.0
</code></pre>
<ul>
<li><strong>Operating System</strong>:</li>
</ul>

<pre><code>root@fsinnosbc:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster
root@fsinnosbc:~# 
</code></pre>

<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/2271">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZLKO4RDY7EXCDC7U4TRKRJ2HANCNFSM4L2FVCCA">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABO7UZPZOCOEIW5WQJ7ITYLRKRJ2HA5CNFSM4L2FVCCKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4I2QRBZQ.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/2271",
"url": "https://github.com/kamailio/kamailio/issues/2271",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>