### Description

Kamailio is setup as a WebRTC to SIP(UDP) gateway. It forwards WSS to UDP and 
UDP to WSS connections.
This was doing fine until 5.8.2 (so 5.8.1 is running perfectly).

Since 5.8.2 (and 5.8.3) the following message is printed on sending towards a 
connected WSS connection:

```
Sep  4 17:02:20 p01t-1 kamailio.webrtc[336177]: WARNING: webrtc:tm 
[../../core/forward.h:204]: msg_send_buffer(): TCP/TLS connection for WebSocket 
could not be found
Sep  4 17:02:20 p01t-1 kamailio.webrtc[336177]: WARNING: webrtc:tm 
[t_fwd.c:1586]: t_send_branch(): sending request on branch 0 failed
Sep  4 17:02:20 p01t-1 kamailio.webrtc[336177]: WARNING: webrtc:<script>: 
Forwarding request failed
Sep  4 17:02:20 p01t-1 kamailio.webrtc[336177]: INFO: webrtc:sl 
[sl_funcs.c:420]: sl_reply_error(): message marked with delayed-reply flag
```

### Troubleshooting

Code: 

- handle_ruri_alias() sets the $du from the alias parameter and looks good: 
- $fs sets the local socket (saved on incoming register to the Contact URI) 
(optional, removed, same result)
- set_forward_no_connect() we cannot connect outbound, the connection must 
exists
- tcp_get_conid("$dd:$dp", "$var(conid)") and well: it is existing!
- reset the R-URI to the contact 
- and send out with t_relay()

```
        # $ru = INVITE 
sip:[email protected]:5063;transport=udp;ntv3=4;alias=1.2.3.4~51820~6;fs=tls:100.100.100.100:443;uri=sip:43130110221%40192.168.63.105%3bline%3dwc-x9u7ra%3bx-ts;line=wc-x9u7ra;x-ts
        if ($(ru{uri.param,alias}{s.len}) && $(ru{uri.param,uri}{s.len})) {
                $var(target) = $rU;

                if (!handle_ruri_alias()) {
                        xlog("L_ERR", ">> Bad alias <$ru>");
                        sl_send_reply("400", "Bad Request");
                        exit;
                }
                if ($(ru{uri.param,fs}{s.len})) {
                        xlog("L_INFO", ">> setting local socket to 
$(ru{uri.param,fs})");
                        $fs = $(ru{uri.param,fs});
                }
                if ($dP =~ "ws|tls|tcp") {
                        set_forward_no_connect();
                        xlog("L_INFO", ">> checking tcp connection to $dd:$dp");
                        if(tcp_get_conid("$dd:$dp", "$var(conid)")) {
                                xlog("L_INFO", ">> connection id to $dd:$dp is: 
$var(conid)");
                        } else {
                                if (is_method("NOTIFY")) {
                                        xlog("L_ERR", ">> connection to $dd:$dp 
is no longer connected. Client must resubscribe!");
                                        sl_send_reply("604", "Please Remove 
Subscription"); 
                                } else {
                                        xlog("L_ERR", ">> connection to $dd:$dp 
is no longer connected. Client must reregister!");
                                        sl_send_reply("480", "TCP not 
connected");
                                }
                                exit;
                        }
                }
                $ru = $(ru{uri.param,uri}{s.unescape.param});
                $rU = $var(target);

                xlog("L_INFO", ">> OUT-CONTACT: $rm $ru ($du) - rP=$rP -> 
dp=$dP nh(P)=$nh(P)");
                route(FORWARD); # route that call immediately
        }


route[FORWARD] {
        xlog("L_INFO", "ROUTE[FORWARD] - R-URI/D-URI: $rm $ru ($du): $mf");

...

        xlog("L_INFO", ">> Forwarding request now");
        if (!t_relay()) {
                xlog("L_WARN", "Forwarding request failed");

...

onsend_route {
        if ($mt==1) {
                xlog("L_INFO", ">>> Sending Request: $rm $ru 
($sndfrom(ip):$sndfrom(port) -> $sndto(ip):$sndto(port): $du)");
                xlog("L_INFO", "$sndto(buf)");
                #!ifdef WITH_HOMER
                # for some reason the ACK flagged in FORWARD is not traced on 
sending out
                if (isflagset(FL_TRACE)) {
                        xlog("L_INFO", ">> FL_TRACE on $rm set!");
                }
                if (is_method("ACK") && isflagset(FL_TRACE)) {
                        sip_trace();
                }
                #!endif
        } else {
                xlog("L_INFO", ">>> Sending Reply: $rs $rr 
($sndfrom(ip):$sndfrom(port) -> $sndto(ip):$sndto(port))");
                xlog("L_INFO", "$sndto(buf)");
        }
}
```

#### Reproduction

Any call to the WebSocket is rejected now. Working fine before 5.8.2.

#### Log Messages

```
 kamailio.webrtc[338351]: INFO: webrtc:<script>: ROUTE[OUTBOUND] - route to 
registered contact: INVITE 
sip:[email protected]:5063;transport=udp;ntv3=4;alias=101.100.100.129~52201~6;fs=tls:100.100.100.131:443;uri=sip:15551234521%40192.168.63.105%3bline%3dwc-x9u7ra%3bx-ts;line=wc-x9u7ra;x-ts
 kamailio.webrtc[338351]: INFO: webrtc:<script>: >> read domain from 
P-Called-Party-ID: ws2.ipbx.tld
 kamailio.webrtc[338351]: INFO: webrtc:<script>: >> Reduce Session Timer from 
1800 to 120
 kamailio.webrtc[338351]: INFO: webrtc:<script>: >> setting local socket to 
tls:100.100.100.131:443

optional. same without $fs=tls:100.100.100.131:443 (ws: and wss: are invalid 
for $fs)

 kamailio.webrtc[338351]: INFO: webrtc:<script>: >> checking tcp connection to 
101.100.100.129:52201
 kamailio.webrtc[338351]: INFO: webrtc:<script>: >> connection id to 
101.100.100.129:52201 is: 1

The connection is found and alive!

 kamailio.webrtc[338351]: INFO: webrtc:<script>: >> OUT-CONTACT: INVITE 
sip:[email protected];line=wc-x9u7ra;x-ts 
(sip:101.100.100.129:52201;transport=ws) - rP=UDP -> dp=ws nh(P)=ws
 kamailio.webrtc[338351]: INFO: webrtc:<script>: ROUTE[FORWARD] - R-URI/D-URI: 
INVITE sip:[email protected];line=wc-x9u7ra;x-ts 
(sip:101.100.100.129:52201;transport=ws): 8388624
 kamailio.webrtc[338351]: INFO: webrtc:<script>: ROUTE[RTPP_REQ]
 kamailio.webrtc[338351]: INFO: webrtc:<script>: ROUTE[RTP_MANAGE]
 kamailio.webrtc[338351]: INFO: webrtc:<script>: > SIP -> WebRTC, bridging 
RTP->SRTP-DTLS and adding ICE - o-313732353436333239323434393936-ytpwonh6n9aq
 kamailio.webrtc[338351]: INFO: webrtc:<script>: ROUTE[RTP_MANAGE] 
method:INVITE, ruri:sip:[email protected];line=wc-x9u7ra;x-ts, 
callid:o-313732353436333239323434393936-ytpwonh6n9aq, 
rtpengine_manage:call-id=o-313732353436333239323434393936-ytpwonh6n9aq 
via-branch=auto trust-address r
eplace-origin replace-session-connection rtcp-mux-accept rtcp-mux-require 
generate-mid SDES-off ICE=force ICE-lite=forward UDP/TLS/RTP/SAVPF pad-crypto
 kamailio.webrtc[338351]: INFO: webrtc:<script>: > rtpengine(): SUCCESS
 kamailio.webrtc[338351]: INFO: webrtc:<script>: >> Forwarding request now

100 trying ...

 kamailio.webrtc[338351]: INFO: webrtc:<script>: >>> Sending Request: INVITE 
sip:[email protected];line=wc-x9u7ra;x-ts (100.100.100.131:443 -> 
101.100.100.129:52201: sip:101.100.100.129:52201;transport=ws)
 kamailio.webrtc[338351]: INFO: webrtc:<script>: INVITE 
sip:[email protected];line=wc-x9u7ra;x-ts SIP/2.0
Record-Route: 
<sip:100.100.100.131:443;transport=ws;r2=on;lr;ftag=ly9574qrtx;x-dir=o;x-rtpp=1>
Record-Route: 
<sip:192.168.48.131:5063;r2=on;lr;ftag=ly9574qrtx;x-dir=o;x-rtpp=1>
Via: SIP/2.0/WSS 
100.100.100.131:443;branch=z9hG4bK727a.06944932aa61c384f55e7cbc0a59ec0a.0
Via: SIP/2.0/UDP 192.168.48.74:5060;branch=z9hG4bKgWoe~Gc5kT
Via: SIP/2.0/UDP 192.168.48.74:5060;branch=z9hG4bKvA3weqaC-e;internal=6715591-1
From: "Walter 22" <sip:[email protected]>;tag=ly9574qrtx
To: <sip:[email protected];user=phone>
Call-ID: 
313732353436333239323434393936-ytpwonh6n9aq-UASession-p1EoqWEkFt-CQ-100-
CSeq: 1 INVITE
Max-Forwards: 67
Supported: replaces,from-change,timer,histinfo
Allow: INVITE,ACK,CANCEL,BYE,INFO,REFER,PRACK,NOTIFY
Contact: <sip:192.168.48.74:5060;internal=6715591-1;type=tpcc>
Content-Length: 649
Content-Type: application/sdp
Record-Route: <sip:192.168.48.74:5060;transport=udp;lr>
Allow-Events: talk,hold,refer
Accept: application/sdp
Session-Expires: 90;refresher=uas

[...] shortened SDP body

 kamailio.webrtc[338351]: INFO: webrtc:<script>: >> FL_TRACE on INVITE set!
 kamailio.webrtc[338351]: INFO: webrtc:<script>: Network sending:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
INVITE sip:[email protected];line=wc-x9u7ra;x-ts SIP/2.0
Record-Route: 
<sip:100.100.100.131:443;transport=ws;r2=on;lr;ftag=ly9574qrtx;x-dir=o;x-rtpp=1>
Record-Route: 
<sip:192.168.48.131:5063;r2=on;lr;ftag=ly9574qrtx;x-dir=o;x-rtpp=1>
Via: SIP/2.0/WSS 
100.100.100.131:443;branch=z9hG4bK727a.06944932aa61c384f55e7cbc0a59ec0a.0
Via: SIP/2.0/UDP 192.168.48.74:5060;branch=z9hG4bKgWoe~Gc5kT
Via: SIP/2.0/UDP 192.168.48.74:5060;branch=z9hG4bKvA3weqaC-e;internal=6715591-1
From: "Walter 22" <sip:[email protected]>;tag=ly9574qrtx
To: <sip:[email protected];user=phone>
Call-ID: 
313732353436333239323434393936-ytpwonh6n9aq-UASession-p1EoqWEkFt-CQ-100-
CSeq: 1 INVITE
Max-Forwards: 67
Supported: replaces,from-change,timer,histinfo
Allow: INVITE,ACK,CANCEL,BYE,INFO,REFER,PRACK,NOTIFY
Contact: <sip:192.168.48.74:5060;internal=6715591-1;type=tpcc>
Content-Length: 649
Content-Type: application/sdp
Record-Route: <sip:192.168.48.74:5060;transport=udp;lr>
Allow-Events: talk,hold,refer
Accept: application/sdp
Session-Expires: 90;refresher=uas

[...] shortened SDP body

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 kamailio.webrtc[338351]: WARNING: webrtc:tm [../../core/forward.h:204]: 
msg_send_buffer(): TCP/TLS connection for WebSocket could not be found
 kamailio.webrtc[338351]: WARNING: webrtc:tm [t_fwd.c:1586]: t_send_branch(): 
sending request on branch 0 failed
 kamailio.webrtc[338351]: WARNING: webrtc:<script>: Forwarding request failed
```

### ~~Possible~~ Solutions

Downgrade to 5.8.1



-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3969
You are receiving this because you are subscribed to this thread.

Message ID: <kamailio/kamailio/issues/[email protected]>
_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to [email protected]

Reply via email to