### Description
I have working Kamailio config for WebRTC clients. I now want to use `tcp_reuse_port` feature and this feature breaks WebRTC clients.
#### Log Messages
``` 106(106803) DEBUG: {1 41089865 ACK d50c83b4-124a-11ec-a038-835ce78b460e} <core> [core/forward.c:578]: forward_request(): orig. len=865, new_len=741, proto=5 106(106803) DEBUG: {1 41089865 ACK d50c83b4-124a-11ec-a038-835ce78b460e} <core> [core/forward.h:169]: msg_send_buffer(): sending to: 109.121.188.190:56424, force_socket=4, send_sock=0xffffa40ffa98 106(106803) WARNING: {1 41089865 ACK d50c83b4-124a-11ec-a038-835ce78b460e} <core> [core/forward.h:203]: msg_send_buffer(): TCP/TLS connection for WebSocket could not be found 106(106803) ERROR: {1 41089865 ACK d50c83b4-124a-11ec-a038-835ce78b460e} sl [sl_funcs.c:418]: sl_reply_error(): stateless error reply used: Unfortunately error on sending to next hop occurred (477/SL) ``` More logs at the attached `ack.log` file. [ask.log](https://github.com/kamailio/kamailio/files/7144893/ask.log)
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
used master branch with small customization, base commit c503d2bd31a580138a67f1d4a265ccde5791d271
* **Operating System**: aarch64 ``` [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" ```
I have added extra logs sctrings and found. This happens because sockaddr_union `from` contains port number 5060 https://github.com/kamailio/kamailio/blob/master/src/core/forward.h#L188-L19...
This port assigned from "dest_info* dst" https://github.com/kamailio/kamailio/blob/master/src/core/forward.h#L174
This struct passed into msg_send_buffer here https://github.com/kamailio/kamailio/blob/master/src/core/forward.h#L117
Need to find why for ACK delivery used not socket where WebRTC client registered, but used socket bound to port 5060.
@sergey-safarov seems you have `force_send_socket` enabled in RR module. Look at L172-L174 from the log you provided, this is where socket_info* struct is being fill in with port 5060 from RR and this data (ie. port) is used as a forced socket later
just quick update: the socket is also forced after loose_route, if you have double_rr enabled and don't use outbound.
yes @arsperger, you are correct. here is the wrong Route header used in `ACK` message. Wrong route header used because of Kamailio inserter wrong `Record-Route` header.
WebRTC client really connected to the socket `tls:3.236.25.254:7001` but Record-Route header generated like ``` INVITE sips:safarov@df7jal23ls0d.invalid;rtcweb-breaker=no;transport=wss SIP/2.0 Record-Route: sips:3.236.25.254;transport=ws;r2=on;lr=on;ftag=j4aU17p3BvH0e;did=698.6e42 Record-Route: sips:[2600:1f18:578:5701::7e];transport=tcp;r2=on;lr=on;ftag=j4aU17p3BvH0e;did=698.6e42 Record-Route: sip:[2600:1f14:6d8:5408::100]:5080;transport=tcp;r2=on;lr=on;ftag=j4aU17p3BvH0e Record-Route: sip:[2600:1f14:6d8:5408::100];transport=tcp;r2=on;lr=on;ftag=j4aU17p3BvH0e Via: SIP/2.0/WSS 3.236.25.254;branch=z9hG4bKa53e.f43ae42f2fefe414dabc1a6739b19bbe.0;i=3 ``` Here is top `Record-Route` should contain port "7001" but really is not.
I was replaced use of `record_route` by ``` record_route_preset("3.236.25.254:7001;transport=ws;r2=on", "[2600:1f18:578:5701::7e];transport=tcp;r2=on"); ``` This alow me to specify which sockets need to use for call dialog and now ACK properly delivered to WebRTC client.
The issue about missed port in `Record-Route` header will be created. This ticket is resolved.
Closed #2849.