Description

I have faced with an issue in Kamailio 5.6 when tcp closed reset by peer on remote side but Kamailio dont executing route block "event_route[websocket:closed]".

Kamailio minimal config file

####### Global Parameters #########

listen=udp:192.168.31.81:5060
listen=tcp:192.168.31.81:5060
listen=tcp:192.168.31.81:7000

tcp_accept_no_cl=yes

######## Kamailio control connector module ########
loadmodule "tm.so"
loadmodule "ctl.so"
modparam("ctl", "binrpc_buffer_size", 4096)
loadmodule "pv.so"
loadmodule "sl.so"
loadmodule "xlog.so"
loadmodule "nathelper.so"
loadmodule "xhttp.so"
loadmodule "websocket.so"
loadmodule "ipops.so"
loadmodule "siputils.so"
loadmodule "rr.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"

request_route {
if(method=="REGISTER"){
save("location");
exit;
}
}

event_route[xhttp:request] {
set_reply_close();
set_reply_no_connect();

    xlog("L_WARN", "websocket|log|connection from $si received!\n");

    if ($hdr(Upgrade)=~"websocket"
                    && $hdr(Connection)=~"Upgrade"
                    && $rm=~"GET") {

            if (ws_handle_handshake())
            {
                    exit;
            }
    }
    xhttp_reply("404", "Not found", "", "");

}

event_route[websocket:closed]
{
xlog("L_WARN", "websocket|log|connection from $si closed!\n");
}

Reproduction

###Kamailio started and client sipml5 connected
[root@centos8 kamailio]# sh /root/run_kamailio.sh
Listening on
udp: 192.168.31.81:5060
tcp: 192.168.31.81:5060
tcp: 192.168.31.81:7000
Aliases:
tcp: centos8.local.tst:7000
tcp: centos8.local.tst:5060
udp: centos8.local.tst:5060

15(29286) WARNING: <script>: websocket|log|connection from 192.168.31.100 received!

closing tcp connection by remote side

C:\Users\Alex>netstat -ano | findstr :7000
TCP 192.168.31.100:51688 192.168.31.81:7000 ESTABLISHED 9624
C:\Users\Alex>taskkill /pid 9624 /F
SUCCESS: The process with PID 9624 has been terminated.

issue reproduced

17(29288) ERROR: [core/tcp_read.c:272]: tcp_read_data(): error reading: Connection reset by peer (104) ([192.168.31.100]:51688 ->17(29288) ERROR: [core/tcp_read.c:274]: tcp_read_data(): -> [192.168.31.81]:7000)
17(29288) ERROR: [core/tcp_read.c:1478]: tcp_read_req(): ERROR: tcp_read_req: error reading - c: 0x7f47d5134ad0 r: 0x7f47d5134bf8 (-1)

And nothing else but I am expecting something like that:
this is output from Kamailio 5.5 where the issue not reproduced.

13(39207) WARNING: websocket [ws_frame.c:227]: encode_and_send_ws_frame(): TCP/TLS connection get failed
13(39207) ERROR: websocket [ws_frame.c:761]: ping_pong(): sending keepalive
14(39208) WARNING: <script>: websocket|log|connection from 192.168.31.100 closed!

Also additional output ws.dump
[root@centos8 kamailio]# kamcmd ws.dump
{
connections: {
}
info: {
wscounter: 0
truncated: no
}
}

Possible Solutions

I found a commit which called this behavior
3033b76

If I was built Kamailo without this commit, the issue not reproduced, also the issue not reproduced in Kamailio 5.5 or older.

Additional Information

[root@centos8 kamailio-5.6]# kamailio -v
version: kamailio 5.6.4 (x86_64/linux) a004cf
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_BLOCKLIST, 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: a004cf 
compiled on 11:09:28 Mar  6 2023 with gcc 8.5.0

[root@centos8 kamailio-5.6]# cat /etc/centos-release 
CentOS Stream release 8


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <kamailio/kamailio/issues/3389@github.com>