[SR-Users] Kamailio does not forward BYE to Asterisk

egemen ulus ulus_egemen at hotmail.com
Mon Sep 14 16:07:57 CEST 2020

Hi Henning,

Thank you for your response. I have checked with debug mode, here is the result; It can't find the dialog that is why it sends "404 Not Here" even though callid is the same.

Dialog that is kept in DB:

dialog memory records
dialog::  hash=1056:7783
        state:: 4
        ref_count:: 2
        timestart:: 1600091398
        timeout:: 90338404
        callid:: 18f82088676a5d7f7c94e4f96c34a41f at asterisk_ip
        from_uri:: sip:90850532xyzt at asterisk_ip
        from_tag:: as00b3f8a9
        caller_contact:: sip:908505326011 at asterisk_ip:5060
        caller_cseq:: 102
        caller_bind_addr:: udp:kamailio_ip:5060
        callee_bind_addr:: udp:kamailio_ip:5060
        to_uri:: sip:333305458596985 at remote_sipserver
        to_tag:: as7cf5b3da
        callee_contact:: sip:333305458596985@:remote_sipserver:5060
        callee_cseq:: 0
        callee_route_set:: <sip:remote_sipserver;lr>

Debug output for BYE message:

NOTICE: acc [acc.c:317]: acc_log_request(): ACC:
transaction answered: timestamp=1600091398;method=BYE;from_tag=as7cf5b3da;to_tag=as00b3f8a9;call_id=18f82088676a5d7f7c94e4f96c34a41f at asterisk_ip;code=404;reason=Not here;src_user=333305458596985;src_domain=remote_sipserver;src_ip=remote_sipserver;dst_ouser=90850532xyzt;dst_user=;dst_domain=kamailio_ip

Bye request header:

BYE sip:90850532xyzt at kamailio_ip SIP/2.0

And this is how I used dlg_manage() in Kamailio cfg (In RELAY):

if (src_ip == x.x.x.x/26) {
                if (is_method("INVITE|ACK")) {
                        $var(x) = $tU;
                        $var(y) = $(var(x){s.striptail,11});
                        sql_pvquery("cb", "select ipaddress from prefixes where prefix = $var(y)", "$var(recieved)");
                        append_hf("Contact: <sip:$fU@$var(recieved)>\r\n", "Call-ID");
                        $fs = "udp:" + $var(recieved) + ":5060";
        if (!t_relay()) {


Egemen U.

Get Outlook for Android<https://aka.ms/ghei36>
From: Henning Westerholt <hw at skalatan.de>
Sent: Monday, September 14, 2020 3:15:48 PM
To: Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org>
Cc: egemen ulus <ulus_egemen at hotmail.com>
Subject: RE: Kamailio does not forward BYE to Asterisk

Hello Egemen,

have you tried to debug it and find out why the BYE is not routed in this particular case from Kamailio? You already mentioned the R-URI, what is in this particular BYE? Is Kamailio listening on all VLAN IPs? Just to share some ideas.

About the performance question, I know of some installation that have about 5-10 interfaces on a box and did not heard of problems so far.

The main topic to consider here (iMHO) is that it gets a bit complicated to handle many different interfaces in one kamailio, so for that reasons it might be a good idea to split it to different VMs or instances.




Henning Westerholt – https://skalatan.de/blog/

Kamailio services – https://gilawa.com<https://gilawa.com/>

From: sr-users <sr-users-bounces at lists.kamailio.org> On Behalf Of egemen ulus
Sent: Friday, September 11, 2020 11:58 AM
To: Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org>
Subject: [SR-Users] Kamailio does not forward BYE to Asterisk

Hi all,

I have an infrastructure with Kamailio (reg), Asterisks farm, and Kamailio (4.3) proxy which dispatches calls.

                                                                                                Trunk-1 (Vlan_A)

Kam(reg) <> Asterisk Farm (5) <> Kam(proxy)     <>      Trunk-2 (Vlan_B)

                                                                                                Trunk-3 (Vlan_C)

For each trunk, I have to use the IP of the VLAN interface in "contact header". That means when I need to send a call to Trunk-1 I have to set Vlan_A IP address on the contact header. I have achieved that by rewriting Contact Header.



append_hf("Contact: <sip:$fU@$var(recieved)>\r\n", "Call-ID");   #by using db


But this causes a problem, Kamailio does not forward the BYE message that comes from Trunk-X to Asterisk (In before, the BYE message had Asterisk IP in R-URI). However, when I use topoh module it forward properly for one trunk. But I can not set multiple mask IP in topoh module.

I'm using the dialog module and I thought it can handle all requests in one dialog to forward to the correct asterisk but it did not.

Is there any suggestion for this case?

And also how many sub-interfaces can Kamailio handle for a good performance?  Or do you suggest multiple Kamailio instances instead of multiple sub-interfaces on one server?


Virus-free. www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20200914/059691d2/attachment.htm>

More information about the sr-users mailing list