Author Topic: simple sip phone dial  (Read 4680 times)

jehanzaib_kiani

  • Newbie
  • *
  • Posts: 43
    • View Profile
simple sip phone dial
« on: November 26, 2014, 10:55:10 PM »
Hi team,

i have used db to register my sip users. this works fine. but when i try to dial this user it does not route and says NOT FOUND.
[user.register]
; Query for the user.register message
query=UPDATE sip_users SET fullcontact='${data}',expires=DATE_ADD(NOW(), INTERVAL ${expires} SECOND) WHERE username='${username}'


i have user 100 is regsiter and calling 100. here is my route.php. the script is run and i see it set the line but dont route and say 404 Not found.

         if ($ev->getValue("called")=="100") {
           $ev->retval = "sip/".$ev->getValue("called");
           $ev->params["line"] = "100";
           //$ev->params["targetid"] = $ev->getValue("callid");
           $ev->handled = true;
           $ev->Acknowledge();
           break;
         }


here r logs
  param['rtp_forward'] = 'possible'
  param['handlers'] = 'register:50,regexroute:100,cdrbuild:50,register:50,route.php:80,gvoice:20,queues:45,yrtp:50,cdrbuild:50,lateroute:75,dbwave:90,analyzer:90,iax:90,tone:90,conf:90,dumb:90,filetransfer:90,sip:90,wave:90,callfork:100,extmodule:100,pbx:100,callgen:100,moh:100,park:100'
  param['line'] = '100'
  param['targetid'] = 'sip/4c578f4d7a34f816/e9155934/'
  param['callto'] = 'sip/100'
  param['error'] = 'offline'


marian

  • Sr. Member
  • ****
  • Posts: 378
    • View Profile
Re: simple sip phone dial
« Reply #1 on: November 27, 2014, 03:01:22 AM »
The register module has its own route handler which route the call to registered user location when the called number matches the registered username.
All you have to do is to remove comments (the ; char) in register.conf, [call.route] section and enable the handler in register.conf:
[general]
call.route=yes

NOTE: A line (used to route calls to it) is an user yate registers to another entity. E.g. yate is the client (user) of another server.

marian

  • Sr. Member
  • ****
  • Posts: 378
    • View Profile
Re: simple sip phone dial
« Reply #2 on: November 27, 2014, 03:03:11 AM »
Looking at your post I noticed you are using different names for table and location field.
Change them in [call.route] also.

jehanzaib_kiani

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: simple sip phone dial
« Reply #3 on: December 02, 2014, 01:54:37 AM »
should i put ${data} in the location field? currently i am not using location.

marian

  • Sr. Member
  • ****
  • Posts: 378
    • View Profile
Re: simple sip phone dial
« Reply #4 on: December 02, 2014, 06:18:55 AM »
Yes. 'location' is the default field name.

NOTE: You can put ${data} in any database field you want as long as you properly return it when routing.

jehanzaib_kiani

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: simple sip phone dial
« Reply #5 on: December 04, 2014, 02:06:19 AM »
weired. i have call.route=yes in register.conf. but all the calls are going to route.php
and if i do a check in route.php phone still does not ring. its ok to route the call via route.php because i have to send the call to voicemail server if it timeouts on the user.
here is my route.php

        Yate::Output("Route Message: " . $ev->name . " id: " . $ev->id . " called: " . $ev->params["called"] . " caller: " . $ev->params["caller"]);
         if ($ev->getValue("called")=="100") {
           $ev->retval = "sip/".$ev->getValue("called");
           $ev->params["line"] = "100";
           $ev->params["targetid"] = $ev->getValue("callid");
           $ev->handled = true;
           $ev->Acknowledge();
           break;
         }


have a look at the attached logs, i can see call goes to route.php but it is again saying offline in the error. i also have now added location in the sip register/unregister query. can you please have a look. thanks. also if i have to timeout the call to my voicemail server how it will be acheived? say after 20 seconds if nobody picks up, route to voicemail.com server.
thanks

marian

  • Sr. Member
  • ****
  • Posts: 378
    • View Profile
Re: simple sip phone dial
« Reply #6 on: December 04, 2014, 02:59:42 AM »
There is no database message sent by register module when routing.
Are you sure you removed comment char from register.conf, call.route section?

jehanzaib_kiani

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: simple sip phone dial
« Reply #7 on: December 04, 2014, 05:53:32 PM »
yah that's weired. please see my attached register.conf
i dont want to use native call.route actually. i want to route it using route.php beacuse after 20 seconds i have to send the call to another IP.
this is for testing where i have checked if the dialed number is 100 then first route it to extension 100 if nobody picks up or busy then forward it to another ip for example myotherip.com  thats what i want

         if ($ev->getValue("called")=="100") {
           $ev->retval = "sip/".$ev->getValue("called");
           $ev->params["line"] = "100";
           //$ev->params["targetid"] = $ev->getValue("callid");
           $ev->handled = true;
           $ev->Acknowledge();
           break;
         }

marian

  • Sr. Member
  • ****
  • Posts: 378
    • View Profile
Re: simple sip phone dial
« Reply #8 on: December 05, 2014, 03:15:14 AM »
Something is wrong.
Make sure you are loading the right register.conf file and restarted yate after changing register.conf.
The configured priority of call.route is 120. In the log you posted register call.route priority is 50.

jehanzaib_kiani

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: simple sip phone dial
« Reply #9 on: December 07, 2014, 12:44:56 AM »
agreed. thats what i am wondered about. when i restart the yate it says register:120 you can see below. but when i make a call i saw register 50. 
what it could be any clue?

param['handlers'] ='engine:100,callgen:100,extmodule:100,cdrcombine:100,cdrbuild:100,ilbcwebrtc:100,isaccodec:100,accfile:100,regfile:100,regexroute:110,analogdetect:120,subscription:120,mysqldb:120,mux:120,socks:120,openssl:120,zlibcompress:120,analyzer:120,enumroute:120,tonedetect:120,callfork:120,stun:120,iax:120,tone:120,filetransfer:120,conf:120,fileinfo:120,pbx:120,dumb:120,queues:120,users:120,wave:120,sip:120,yrtp:120,gvoice:120,park:120,monitoring:120,presence:120,queuesnotify:120,cache:120,register:120,snmpagent:120,mrcp:120,sipfeatures:120'

jehanzaib_kiani

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: simple sip phone dial
« Reply #10 on: December 07, 2014, 01:21:06 AM »
also

  param['rtp_forward'] = 'possible'
  param['handlers'] = 'register:50,regexroute:100,cdrbuild:50,route.php:80,gvoice:20,queues:45,yrtp:50,cdrbuild:50,lateroute:75,dbwave:90,analyzer:90,iax:90,tone:90,conf:90,dumb:90,filetransfer:90,sip:90,wave:90,callfork:100,extmodule:100,pbx:100,callgen:100,moh:100,park:100'
  param['line'] = '100'
  param['targetid'] = 'sip/6213646a5a29720d/2e57b003/'
  param['callto'] = 'sip/100'
  param['error'] = 'offline'

here the logs says error is offline. unable to figure out where the issue

marian

  • Sr. Member
  • ****
  • Posts: 378
    • View Profile
Re: simple sip phone dial
« Reply #11 on: December 08, 2014, 05:12:02 AM »
The register appearing in handlers parameter is set when call.preroute message is handled. When call.preroute succeeds it is renamed to call.route and re-dispatched: this is the reason register appears there.

The call is routed by route.php. Priority 80.
If you want the routing to be handled nu register before route.php set a lower value priority in it (lower value means higher priority).

jehanzaib_kiani

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: simple sip phone dial
« Reply #12 on: December 08, 2014, 06:41:12 AM »
Actually i want to handle the call by route.php so its fine. but its not working i tried all the possibilities.
The below should work, but its not. any clue please

           $ev->retval = "sip/".$ev->getValue("called");
           $ev->params["line"] = "100";
           //$ev->params["targetid"] = $ev->getValue("callid");
           $ev->handled = true;
           $ev->Acknowledge();
           break;
         }

marian

  • Sr. Member
  • ****
  • Posts: 378
    • View Profile
Re: simple sip phone dial
« Reply #13 on: December 08, 2014, 06:56:49 AM »
As noted in November 27 post a line is an account registered by yate to another server.

If you want to route a call to an user registered to yate you should either:
1. Let register route the call
2. Query the database to retrieve user location and route the call to it

jehanzaib_kiani

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: simple sip phone dial
« Reply #14 on: December 09, 2014, 02:24:01 AM »
sure let's say i have location saved and now i want to route it.

the location is sip/sip:100@xx.xx.xx.xx:6055

how to route in route.php to this location?

         $location = my above location value from db
         if ($ev->getValue("called")=="100") {
           $ev->retval = $location;
           $ev->params["line"] = "100";
           //$ev->params["targetid"] = $ev->getValue("callid");
           $ev->handled = true;
           $ev->Acknowledge();
           break;
         }

will this work? and how to timeout on busy or no answer? if the call timeouts or busy i will put different server IP in the location and route to anywhere else. that;s what i want. Can you please guide this ? ihave hard time to get this done