<p>Hi, all</p>
<p>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:</p>
<p>kamailio server 1(k1): 10.0.1.30:5061<br>
kamailio server 2(k2): 10.0.1.32:5061<br>
sip client c1: sip:16317@10.0.1.30<br>
sip client c2: sip:72316@10.0.1.30</p>
<p>c1 is registered with k1.<br>
c2 is registered with k2.</p>
<p>When c1 calls c2, the call flow is as follows:<br>
INVITE:<br>
c1------>k1------>k2------>c2<br>
200 OK:<br>
c1<------k1<------k2<------c2</p>
<p>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.<br>
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.</p>
<p>BYE:<br>
c1 k1<------k2<------c2<br>
|<br>
|------->Connection refused/500</p>
<p>Here is the kamailio log on k1:<br>
Mar 16 10:34:21 kamailio.sip.com /usr/sbin/kamailio[13396]: ERROR: [tcp_main.c:2740]: tcpconn_1st_send(): connect 10.0.1.30:55999 failed (RST) Connection refused<br>
Mar 16 10:34:21 kamailio.sip.com /usr/sbin/kamailio[13396]: ERROR: [tcp_main.c:2750]: tcpconn_1st_send(): 10.0.1.30:55999: connect & send for 0x7fc96a68a1a0 failed: Connection refused (111)</p>
<p>This is the routing logic for BYE in kamailio.cfg:<br>
if (loose_route()) {<br>
route(DLGURI);<br>
if (is_method("BYE")) {<br>
xlog("L_DBG", "=====BYE $ru from $fu $si:$sp to $du=====\n");<br>
dlg_manage();<br>
setflag(FLT_ACC); # do accounting ...<br>
setflag(FLT_ACCFAILED); # ... even if the transaction fails<br>
}<br>
else if ( is_method("ACK") ) {<br>
# ACK is forwarded statelessy<br>
route(NATMANAGE);<br>
}<br>
else if ( is_method("NOTIFY") ) {<br>
# Add Record-Route for in-dialog NOTIFY as per RFC 6665.<br>
record_route();<br>
}<br>
route(RELAY);<br>
exit;<br>
} else {......</p>
<p>If I add location based routing for BYE from peer kamailio, then the BYE seems to be forwarded correctly:<br>
if (loose_route()) {<br>
route(DLGURI);<br>
if (is_method("BYE")) {<br>
xlog("L_DBG", "=====BYE $ru from $fu $si:$sp to $du=====\n");<br>
dlg_manage();<br>
setflag(FLT_ACC); # do accounting ...<br>
setflag(FLT_ACCFAILED); # ... even if the transaction fails<br>
# If BYE coming from Kamailio peer, route BYE by location<br>
$var(peerlist)=$sel(cfg_get.trusted.peers);<br>
$var(i) = 0;<br>
while($var(i)<$(var(peerlist){param.count})) {<br>
xlog("L_DBG", "=====$(var(peerlist){param.count})=====$(var(peerlist){param.valueat,$var(i)})=====\n");<br>
if(src_ip==$(var(peerlist){param.valueat,$var(i)})) {<br>
lookup("location");<br>
xlog("L_DBG", "=====BYE from $fu $si:$sp to $du=====\n");<br>
break;<br>
}<br>
$var(i) = $var(i) + 1;<br>
}<br>
}<br>
else if ( is_method("ACK") ) {<br>
# ACK is forwarded statelessy<br>
route(NATMANAGE);<br>
}<br>
else if ( is_method("NOTIFY") ) {<br>
# Add Record-Route for in-dialog NOTIFY as per RFC 6665.<br>
record_route();<br>
}<br>
route(RELAY);<br>
exit;<br>
} else {......</p>
<p>My first question is why k1 loose_route sends the BYE to itself instead of the client. Is this a bug? <br>
My next question is whether the above location routing for BYE from peer kamailio a good/safe approach.</p>
<p>Thanks</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/kamailio/kamailio/issues/110">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36Za5CWLCnx88d6ATDNjIeCvq1ts0Iks5n10lVgaJpZM4DvoRJ.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/kamailio/kamailio/issues/110"></link>
<meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>