Author Topic: round robin routing using db query  (Read 31321 times)

jehanzaib_kiani

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: round robin routing using db query
« Reply #15 on: August 29, 2014, 04:55:38 AM »
All good, figured it out from the logs that the path was not correct so if you have default path then you need to comment the below line. so just use route.php=
[scripts]
route.php=
;share/yate/scripts/route.php=

This has resolved the issue, now i can see route.php is being called. i will explore it more in a few days.
All looks good so far. much appreciated for your help.

Cheers!

jehanzaib_kiani

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: round robin routing using db query
« Reply #16 on: November 04, 2014, 10:57:18 PM »
Hi team,

The routing worked for a few times then it stop working.

please see the attached log file, looks like the route.php is loaded successfully but its not called when i have dialed the number. the call was dialed successfully but it did not call the route.php
script does not have any error.
any idea what it could be ?

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: round robin routing using db query
« Reply #17 on: November 05, 2014, 08:10:32 AM »
Hi,

Enable message sniffer (telnet command: msgsniff on).
Check the call.route message 'handlers' parameter. On return it should show the name of the message handler(s) processing it.

jehanzaib_kiani

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: round robin routing using db query
« Reply #18 on: November 05, 2014, 10:17:26 PM »
hi there,
yes i have enabled the sniffer i cant see anything in the call.route Return. but i can see the priority of route.php is 80.
please see the attached sniffer for reference.

yate.conf247.com  (is my yate server)
xx.xx.xx.xx    (is my eyeabeam softphone ip)
100extension (is my eyebeam extension)
mysipserer.com (is my sipserver where i route the call - in regexroute,,conf)

let me know if you can find anything. thanks

jehanzaib_kiani

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: round robin routing using db query
« Reply #19 on: November 05, 2014, 10:18:01 PM »
sorry here is the file attached

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: round robin routing using db query
« Reply #20 on: November 06, 2014, 07:58:52 AM »
Hi,

Your script is receiving the message and don't handle it.
See handlers='register:50,regexroute:100,cdrbuild:50,register:50,route.php:80,fileinfo:90,subscription:100,iax:100,regexroute:100'
The message is handled by regexroute.
Check the script to see why it doesn't handle the message.


jehanzaib_kiani

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: round robin routing using db query
« Reply #21 on: November 06, 2014, 09:53:46 PM »
i figured it out, the route.php was not returning anything but the error i should see is Not Permitted but i saw the sip response as 404 Not Found

                 $ev->error = "Not Permitted";
                 $ev->handled = true;


If i $ev->Acknowledge(); the call then it follows the regexroute.conf route and routed to my provider sip server with other parameters like what i set in the regexroute.conf , also set the osip_Yatebillid like i am doing in the regexroute.conf,  is there anyways i route the call directly from here i mean from route.php.
i have not found any guide from yate wiki on this.

much appreciated for your help. thanks

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: round robin routing using db query
« Reply #22 on: November 07, 2014, 08:24:02 AM »
Yes, you can.
Set the call target in call.route event retval.
E.g.:
$ev->retval = "sip/sip:1@1.2.3.4";
$ev->handled = true;
$ev->Acknowledge();

jehanzaib_kiani

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: round robin routing using db query
« Reply #23 on: November 09, 2014, 11:36:17 PM »
sure thanks.
but how will i set the osip_Yatebillid header if i want to ? like i am setting in regexroute.conf osip_Yatebillid=${billid};

thanks

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: round robin routing using db query
« Reply #24 on: November 10, 2014, 10:21:55 AM »
To set message parameters use the SetParam method.
To obtain message params use the GetValue method.

$ev->SetParam("osip_Yatebillid",$ev->GetValue("billid"));

jehanzaib_kiani

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: round robin routing using db query
« Reply #25 on: November 11, 2014, 12:33:11 AM »
thanks. actually i have to replace regexroute.conf line

^1.*$=fork $(index,$idx01,| sip/sip:\0@mysip1.com,| sip/sip:\0@mysip2.com);osip_Yatebillid=${billid};rtp_forward=true;maxcall=30000


To route.php  can you please check if the below is fine. no idea how to route to mysip2.com if the mysip1.com will be down.
        $ev->SetParam("osip_Yatebillid",$ev->GetValue("billid"));
        $ev->SetParam("rtp_forward",true);
        $ev->SetParam("maxcall",30000);
        $ev->retval = "sip/sip:1@mysip1.com";
        $ev->handled = true;

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: round robin routing using db query
« Reply #26 on: November 11, 2014, 05:40:05 AM »
I'm not a good php programmer but it seems fine to me.

If you want to call on both targets (and rotate them) using fork I suppose you can:

Global variable:
$firstProvider = true;

In handler:

$ev->SetParam("callto.2","|");
if ($firstProvider) {
    $ev->SetParam("callto.1","sip/sip:1@mysip1.com");
    $ev->SetParam("callto.3","sip/sip:1@mysip2.com");
}
else {
    $ev->SetParam("callto.1","sip/sip:1@mysip2.com");
    $ev->SetParam("callto.3","sip/sip:1@mysip1.com");
}
$firstProvider = !$firstProvider;
$ev->retval = "fork";