Hi, all
I'm trying to set up 2 kamailio servers for active-active redundancy. The two kamailio severs share the the same database with db_mode=3, and no registration replication. Use pjsua2 as SIP client for testing. The test setup is as follows:
kamailio server 1(k1): 10.0.1.30:5061 kamailio server 2(k2): 10.0.1.32:5061 sip client c1: sip:16317@10.0.1.30 sip client c2: sip:72316@10.0.1.30
c1 is registered with k1. c2 is registered with k2.
When c1 calls c2, the call flow is as follows: INVITE: c1------>k1------>k2------>c2 200 OK: c1<------k1<------k2<------c2
So far, the INVITE works. c1 and c2 can establish a call. However, when c2 hangs up and sends BYE, the BYE is forwarded all the way to k1, and then k1 gives a 500 server error. The log on k1 seems to indicate k1 was attempting to create a TLS connection to itself instead of using the existing TLS connection to c1 to forward the BYE.
BYE: c1 k1<------k2<------c2 | |------->Connection refused/500
Here is the kamailio log on k1: Mar 16 10:34:21 kamailio.sip.com /usr/sbin/kamailio[13396]: ERROR: <core> [tcp_main.c:2740]: tcpconn_1st_send(): connect 10.0.1.30:55999 failed (RST) Connection refused Mar 16 10:34:21 kamailio.sip.com /usr/sbin/kamailio[13396]: ERROR: <core> [tcp_main.c:2750]: tcpconn_1st_send(): 10.0.1.30:55999: connect & send for 0x7fc96a68a1a0 failed: Connection refused (111)
This is the routing logic for BYE in kamailio.cfg: if (loose_route()) { route(DLGURI); if (is_method("BYE")) { xlog("L_DBG", "=====BYE $ru from $fu $si:$sp to $du=====\n"); dlg_manage(); setflag(FLT_ACC); # do accounting ... setflag(FLT_ACCFAILED); # ... even if the transaction fails } else if ( is_method("ACK") ) { # ACK is forwarded statelessy route(NATMANAGE); } else if ( is_method("NOTIFY") ) { # Add Record-Route for in-dialog NOTIFY as per RFC 6665. record_route(); } route(RELAY); exit; } else {......
If I add location based routing for BYE from peer kamailio, then the BYE seems to be forwarded correctly: if (loose_route()) { route(DLGURI); if (is_method("BYE")) { xlog("L_DBG", "=====BYE $ru from $fu $si:$sp to $du=====\n"); dlg_manage(); setflag(FLT_ACC); # do accounting ... setflag(FLT_ACCFAILED); # ... even if the transaction fails # If BYE coming from Kamailio peer, route BYE by location $var(peerlist)=$sel(cfg_get.trusted.peers); $var(i) = 0; while($var(i)<$(var(peerlist){param.count})) { xlog("L_DBG", "=====$(var(peerlist){param.count})=====$(var(peerlist){param.valueat,$var(i)})=====\n"); if(src_ip==$(var(peerlist){param.valueat,$var(i)})) { lookup("location"); xlog("L_DBG", "=====BYE from $fu $si:$sp to $du=====\n"); break; } $var(i) = $var(i) + 1; } } else if ( is_method("ACK") ) { # ACK is forwarded statelessy route(NATMANAGE); } else if ( is_method("NOTIFY") ) { # Add Record-Route for in-dialog NOTIFY as per RFC 6665. record_route(); } route(RELAY); exit; } else {......
My first question is why k1 loose_route sends the BYE to itself instead of the client. Is this a bug? My next question is whether the above location routing for BYE from peer kamailio a good/safe approach.
Thanks
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/110
You have to provide the SIP trace with all packets from INVITE to the BYE in order to see the routing headers.
Also, it is more appropriate to use <sr-users [at] lists.sip-router.org> mailing list for this kind of needs. The tracker here is intended mainly for bugs in the C code or new feature requests, reaching a smaller group of people, the developers. On sr-users you will get access to the wider community that deals with configuration files.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/110#issuecomment-82616823
OK, I'll forward this email with the SIP traces to sr-users and close this issue here. Thanks.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/110#issuecomment-82994703
Closed #110.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/110#event-258207969
Moved to sr-users.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/110#issuecomment-82996432