<p></p>
<h3>Description</h3>
<p>When call routed to WebRTC client and used <code>record_route()</code>, then Record-Router header does not contain port of socket where WebRTC client connected.<br>
When used <code>tcp_reuse_port = yes</code>, then <code>ACK</code> cannot be delivered to WebRTC client (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="993358597" data-permission-text="Title is private" data-url="https://github.com/kamailio/kamailio/issues/2849" data-hovercard-type="issue" data-hovercard-url="/kamailio/kamailio/issues/2849/hovercard" href="https://github.com/kamailio/kamailio/issues/2849">#2849</a>).</p>
<h4>Reproduction</h4>
<p>I prepared a minimal config that allows reproduce the issue and attached a log file for the test call.</p>
<pre><code># use compact IPv6 addresses
ipv6_hex_style = "c"
enable_tls=1
tcp_accept_no_cl=yes

######## Kamailio control connector module ########
loadmodule "ctl.so"
modparam("ctl", "binrpc_buffer_size", 4096)
loadmodule "pv.so"
loadmodule "sl.so"
loadmodule "xlog.so"
loadmodule "tls.so"
loadmodule "nathelper.so"
modparam("tls", "config", "/etc/kamailio/tls.cfg")
loadmodule "xhttp.so"
loadmodule "websocket.so"
loadmodule "ipops.so"
loadmodule "siputils.so"
loadmodule "rr.so"

loadmodule "debugger.so"
modparam("debugger", "cfgtrace", 1)
modparam("debugger", "log_level_name", "exec")
log_stderror=yes


# IPv4 listeners
listen=udp:eth0:5060
listen=tcp:eth0:5060
listen=tls:eth0:5061
listen=tls:eth0:7001

# IPv6 listeners
listen=udp:[2600:1f18:578:5701::7e]:5060
listen=tcp:[2600:1f18:578:5701::7e]:5060
listen=tls:[2600:1f18:578:5701::7e]:5061
listen=tls:[2600:1f18:578:5701::7e]:7001

request_route {
    if (!has_totag()) {
        record_route();
    }

    if (is_ipv4($si)) {
        route(WEBRTC_PBX);
    } else {
        route(PBX_WEBRTC);
    }
}

route[WEBRTC_PBX] {
    set_contact_alias();
    $du = "sip:[2600:1f14:6d8:5409::100]:5080;transport=tcp";
    forward();
    exit;
}

route[PBX_WEBRTC] {
    handle_ruri_alias();
    forward();
    exit;
}

event_route[xhttp:request] {
    if (!($hdr(Upgrade)=~"websocket"
            && $hdr(Connection)=~"Upgrade"
            && $rm=~"GET")) {
        $var(status_code) = 400;
        $var(reason_phrase) = "Bad Request";
        xhttp_reply("$var(status_code)", "$var(reason_phrase)", "text/plain", "$var(reason_phrase)");
        exit;
    }

    if (!ws_handle_handshake()) {
        $var(status_code) = 400;
        $var(reason_phrase) = "Bad Request";
        xhttp_reply("$var(status_code)", "$var(reason_phrase)", "text/plain", "$var(reason_phrase)");
        exit;
    }

    exit;
}
</code></pre>
<h4>Log Messages</h4>
<p>For Call-ID: a8c7450a-131c-11ec-9546-a727fc4b684e</p>
<pre><code>INVITE sips:safarov@df7jal23ls0d.invalid;rtcweb-breaker=no;transport=wss SIP/2.0^M
Record-Route: <sips:3.236.25.254;transport=ws;r2=on;lr;ftag=FNBFNvy0atDeK>^M
Record-Route: <sips:[2600:1f18:578:5701::7e];transport=tcp;r2=on;lr;ftag=FNBFNvy0atDeK>^
</code></pre>
<p>Client connected to socket <code>tls:3.236.25.254:7001</code> but using <code>record_route()</code> generated</p>
<pre><code>Record-Route: <sips:3.236.25.254;transport=ws;r2=on;lr;ftag=FNBFNvy0atDeK>
</code></pre>
<p>Full logs at <a href="https://github.com/kamailio/kamailio/files/7148185/kam.log">kam.log</a></p>
<h3>Additional Information</h3>
<ul>
<li>
<p><strong>Kamailio Version</strong> - output of <code>kamailio -v</code><br>
used master branch with small customization, base commit  <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/kamailio/kamailio/commit/c503d2bd31a580138a67f1d4a265ccde5791d271/hovercard" href="https://github.com/kamailio/kamailio/commit/c503d2bd31a580138a67f1d4a265ccde5791d271"><tt>c503d2b</tt></a></p>
</li>
<li>
<p><strong>Operating System</strong>:<br>
aarch64</p>
</li>
</ul>
<pre><code>[root@tmp kamailio]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
</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/2850">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZK72DA5HLKEMGQSQ7TUBOBL7ANCNFSM5D3D5SAQ">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<img src="https://github.com/notifications/beacon/ABO7UZIBCGPHQRQVU7SYQGDUBOBL7A5CNFSM5D3D5SA2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4OZ5NREQ.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/2850",
"url": "https://github.com/kamailio/kamailio/issues/2850",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>