Hi Ariel.

 

The problem with Your routing logic is that You don't route in-dialog messages.

Basically, Your request_route should look something like this:

 

request_route {

 

# per request initial checks

route(REQINIT);

 

# CANCEL processing

if (is_method("CANCEL"))

{

if (t_check_trans())

t_relay();

exit;

}

 

# handle requests within SIP dialogs

route(WITHINDLG);

 

# record routing for dialog forming requests (in case they are routed)

# - remove preloaded route headers

remove_hf("Route");

if (is_method("INVITE|SUBSCRIBE"))

record_route();

 

if ($rU==$null)

{

# request with no Username in RURI

sl_send_reply("484","Address Incomplete");

exit;

}

 

if (is_method("INVITE"))

route(LOADBALANCE);

 

route(RELAY);

}

 

There is a lot of things (like initial messages checks) that should be done before routing the message to Media server.

As You can see, route(WITHINDLG) is called even before route(LOADBALANCE). This ensures that messages following the INVITE (BYE included) will be routed

to Media server (which will solve your problem).

However, when calling route(WITHINDLG) You should take care when recieving INVITE with preloaded set of Route headers. They might cause Kamailio to consider the INVITE

within other dialog and route it incorectly (completely bypassing the Media server).

It is also a good practice to use the DIALOG module to keep track about ongoing calls and log them in the database (for example).


The request_route I wrote above might require some customization from You, in order to take care about requests You don't wish to forward to

Media servers (such as Presence related requests and so on..).

 

In route(LOADBALANCE) you should have something like this:

 

route[LOADBALANCE] {

if(!ds_select_dst("0", "4"))

{

xlog("L_NOTICE", "---- No Media server available! sending 404 and exiting.");

send_reply("404", "No destination");

exit;

}

xlog("L_DBG", "--- Media server selected! Going to <$ru> via <$du>\n");

#for failure speed:

t_set_fr(0,2000);

return;

}

 

Your failure_route looks ok, no changes there I would say.

 

Cheers,

Martin

______________________________________________________________
> Od: "Ariel Wainer" <awainer@contentamobile.com>
> Komu: <sr-users@lists.sip-router.org>
> Dátum: 19.04.2013 17:43
> Predmet: [SR-Users] Load balancer using dispatcher / BYE relaying
>

StartFragmentHi, I'm new to Kamailio and I'm trying to setup a load
balancer using Kamailio 4.0 and rtpproxy, to balance between 2 asterisk
servers that provide an IVR service.

I've followed several guides, and so far it seems to work along with
rtpproxy, except it is not sending the BYE message back to asterisk, and
the call never finishes from the asterisk POV.
Let me describe the test scenario: I have the following:
IP phone: 192.168.200.183
PBX: 192.168.200.3
Kamailio: 192.168.200.132
IVR1: 192.168.200.160

IVR2: 192.168.200.161


>From the IP phone which is registered on the PBX, I initiate a call to
exten 800, PBX forwards it to 1234@192.168.200.132:5060 and Kamailio
dispatches it to one of the two IVR in round-robin.
I'm testing this way and not calling directly to Kamailio because in the
production enviroment, calls will be coming from outside.


Attached you will find the Kamailio configuration.
Packet capture made at the Kamailio host, where you can see the BYE
package from the
PBX (first one on line 24) but no BYE package sent to the IVRs is here:
http://cringer.3kh.net/web/misc/sip.cap


Please let me know if I ommited any important detail of my setup and
thanks in advance.


Best regards.

--
Ariel Wainer





----------

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users