Getting Asterisks to work with Tesco IAX2 refresh 0 issue

Tesco’s has jumped on the VOIP band wagon and have created there own VOIP service based on IAX2 tescointernetphone.com. They have they own softphones and hardware phones but getting this to work with Asterisks is going to be a bit of a pain. Outbound works fine with out any problems but inbound is a issue from doing a bit of searching I found a Asterisk user who had the same problem and found that the problem was that the iax connection was not registering it self like normal connections becuase the refreshes rate is returned as 0.

I have traced this out and can see the problem

[color=red] REFRESH : 0[/color]

*CLI> iax2 reload
  == Parsing '/etc/asterisk/iax.conf': Found
  == Parsing '/etc/asterisk/iax_additional.conf': Found
    -- doing lookup for 'gateway.tescointernetphone.com'
    -- doing lookup for 'gateway.tescointernetphone.com'
Tx-Frame Retry[000] -- OSeqno: 000 ISeqno: 000 Type: IAX     Subclass: REGREQ
   Timestamp: 00012ms  SCall: 00002  DCall: 00000 [202.148.48.108:4569]
   USERNAME        : XXXXXXXXXXX
   REFRESH         : 60

  == Loaded firmware 'iaxy.bin'
  == Parsing '/etc/asterisk/iaxprov.conf': Found
    -- Loaded provisioning template 'default'
Rx-Frame Retry[ No] -- OSeqno: 000 ISeqno: 001 Type: IAX     Subclass: REGAUTH
   Timestamp: 00005ms  SCall: 00393  DCall: 00002 [202.148.48.108:4569]
   AUTHMETHODS     : 3
   CHALLENGE       : XXXXXXXXXXX
   USERNAME        : XXXXXXXXXXX

Tx-Frame Retry[000] -- OSeqno: 001 ISeqno: 001 Type: IAX     Subclass: REGREQ
   Timestamp: 00320ms  SCall: 00002  DCall: 00393 [202.148.48.108:4569]
   USERNAME        : XXXXXXXXXXX
   REFRESH         : 60
   MD5 RESULT      : XXXXXXXXXXX

Rx-Frame Retry[ No] -- OSeqno: 001 ISeqno: 002 Type: IAX     Subclass: REGACK
   Timestamp: 00313ms  SCall: 00393  DCall: 00002 [202.148.48.108:4569]
   USERNAME        : XXXXXXXXXXX
   DATE TIME       : 2006-10-29  12:49:58
REFRESH         : 0 <--------------------------------------------------------------
   APPARENT ADDRES : IPV4 58.106.XX.X:4569

    -- Registered IAX2 to '202.148.48.108', who sees us as 58.106.XX.X:4569 with no messages waiting

Tx-Frame Retry[-01] -- OSeqno: 002 ISeqno: 002 Type: IAX     Subclass: ACK
   Timestamp: 00313ms  SCall: 00002  DCall: 00393 [202.148.48.108:4569]

Comments from scots voip blog sums it up pretty well scotsvoiplog.blogspot.com/

[quote]When asterisk registers itself with Tesco, one of the parameters that gets sent back is the length of time between registration refreshes (which lets Tesco know that I’m still online and listening). If asterisk doesn’t recieve that parameter back, it assumes that it should refresh every 60 seconds. However, Tesco send back a value of 0, which gives the following little warning from asterisk:

Aug 12 21:57:19 NOTICE[3917]: sched.c:234 ast_sched_add_variable: Scheduled event in 0 ms?

A side effect of getting sent a refresh value of 0 is that Asterisk never sends out a registration refresh request, so Tesco assumes that we’ve gone offline. From what I’ve been able to gather from seaching through google and looking at the source to asterisk, there is no way to overide the setting that gets sent from the server (though I could be wrong). As such, I modified the source so that if it gets a value of 0, it changes it to 60. So far, this seems to work.[/quote]

As you can see this is not a problem of Asterisk but I dont think I can very well turn round to Tesco and say change your register refresh rate I was thinking to see if there could be a script that could be run to register the IAX trunk again after X amount of seconds or maybe some other work around like scott has done.

Hi

Tesco are only a reseller of the freshtel service IIRC. SO it may be worth checking the whirlpool.au site to see if they have any answers.

Ian

Thanks ianplain I did know it was a resell of a freshtel service :smile: but thanks for the hint whirlpool.au did lead me to a freshtel rep so I might fire him a quick mail and see what he says. Looking at other configs for freshtel no one seems to have had this problem so maybe this is just some thing they have left on with the tesco service

Mmmm no luck with the link looks like freshtel outsource the support and running of the service to some one else so might have to look for a inhouse fix :smile:

I have seen in the code where the check comes but as I am not a programer I dont have enough brian power on how to code this simple fix


00214 int ast_sched_add_variable(struct sched_context *con, int when, ast_sched_cb callback, void *data, int variable)
00215 {
00216 struct sched *tmp;
00217 int res = -1;
00218 DEBUG(ast_log(LOG_DEBUG, "ast_sched_add()\n"));
00219 if (!when) {
00220 ast_log(LOG_NOTICE, "Scheduled event in 0 ms?\n");
00221 return -1;
00222 }

i would have thought a quick and dirty fix would be something like00214 int ast_sched_add_variable(struct sched_context *con, int when, ast_sched_cb callback, void *data, int variable) 00215 { 00216 struct sched *tmp; 00217 int res = -1; 00218 DEBUG(ast_log(LOG_DEBUG, "ast_sched_add()\n")); 00219 if (!when) { 00220 ast_log(LOG_NOTICE, "Scheduled event in 0 ms?\n"); 00221 when = 60000; 00222 }
thereby bypassing the return from that check and setting a 60 second time

but i wonder what else might be killed !!

oh yeah, i know squat about C programming :smiley:

Thanks baconbuttie I need to speak I guess with some one who knows the code a little bit better than I do :smile: to try and point out if there are any other areas that this needs to updated to then I guess it will come down to the compile :frowning: not looking forward to that… As I am a trixbox user and aways had it easy point and click installs and nice WEB gui :smile:

i would just go for it ! at least then, when you create a bug report (is it a bug ??) you’ll be able to say what you did to get it working :smiley:

seriously, try it.

Well After lots of research it looks like I need to recompile asterisk to support my VOIP provider as they are sending a Refresh 0 so trixbox is not reregistering the connection.

Looking at a few posts it looks like this is the fastest way to screw up your system :frowning: apart from taking a backup are there any hints or tips that I should know before I take this road :frowning: I found a few notes on the system abotu doing please let me know if I missed any thing.

does TrixBox include the source in /usr/src or is it somewhere else ?

downloading the source straight from Digium will break additional apps like RxFax/TxFax, and anything extra you may or may not be using. if the source is there, just make the change in the .c file and while in the Asterisk source directory do a make clean && make

if it b0rks during compilation then just reverse the change to the source. if it compiles ok then do a make install. if that kills it then reverse the source change, recompile and install to get back to where you were.

Hi baconbuttie no such luck just had a quick look in /usr/src there is some source code but nothing for asterisk :frowning:

See I am a little worried as I just have linux and asterisk up and running the way I want so dont wont to b0rks but then if I wanted a easy life I would have stayed with windows 95 will do a little bit more google home work before I get a little bit 2 carried away

the source should be somewhere, try using “find / -name sched.c”

if not, as i said earlier, you could download the current tarball, patch where needed (with your fix and any additional apps) and compile.

Good news after making a post on the mailing list Tim from mexuar.com gave me a idea to try and add qualify=60 to the iax.conf looks like it is working :smile: but sad not to have to compile and add my own patch to Asterisk

Mmmm well the IAX2 channel shows it is registered but no calls come in all calls still get sent to tescos voice mail meaning it either can’t connect to my system or I am not correctly registered to the system.

Well still no inbound calls So I guess I have to try and debug every thign and work out where the problem lies.

iax2 show registry shopws

where 111.111.111.111 is my exturnal Ip and 12345678 is my phonenumber/username

Host                  Username    Perceived             Refresh  State
202.148.48.108:4569   12345678   111.111.111.111:4569           0  Registered

Now should I be able to telnet to the 4569 port on my local pc


[root@pabx ~]# telnet 127.0.0.1 4569
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host: Connection refused
[root@pabx ~]# telnet 192.168.0.103 4569
Trying 192.168.0.103...
telnet: connect to address 192.168.0.103: Connection refused
telnet: Unable to connect to remote host: Connection refused
[root@pabx ~]#

What ports need to be open to allow the call to come in ?

[root@pabx ~]# nmap -sT -O localhost

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2006-11-06 23:05 EST
Interesting ports on asterisk1.local (127.0.0.1):
Not shown: 1671 closed ports
PORT      STATE SERVICE
21/tcp    open  ftp
22/tcp    open  ssh
25/tcp    open  smtp
80/tcp    open  http
111/tcp   open  rpcbind
443/tcp   open  https
637/tcp   open  lanserver
3306/tcp  open  mysql
10000/tcp open  snet-sensor-mgmt
Device type: general purpose
Running: Linux 2.4.X|2.5.X|2.6.X
OS details: Linux 2.5.25 - 2.6.8 or Gentoo 1.2 Linux 2.4.19 rc1-rc7, Linux 2.6.3
 - 2.6.10
Uptime 0.150 days (since Mon Nov  6 19:29:52 2006)

Nmap finished: 1 IP address (1 host up) scanned in 3.239 seconds

if it’s IAX2 then 4569 UDP

I have that open and port forwarded to asterisk on the firewall but nothing is listening on that port not sure why.

[root@pabx ~]# lsof -a -i -u asterisk
COMMAND     PID     USER   FD   TYPE DEVICE SIZE NODE NAME
httpd      2583 asterisk    3u  IPv4   5674       TCP *:http (LISTEN)
httpd      2583 asterisk    4u  IPv6   5677       TCP *:https (LISTEN)
httpd      2584 asterisk    3u  IPv4   5674       TCP *:http (LISTEN)
httpd      2584 asterisk    4u  IPv6   5677       TCP *:https (LISTEN)
httpd      2585 asterisk    3u  IPv4   5674       TCP *:http (LISTEN)
httpd      2585 asterisk    4u  IPv6   5677       TCP *:https (LISTEN)
httpd      2586 asterisk    3u  IPv4   5674       TCP *:http (LISTEN)
httpd      2586 asterisk    4u  IPv6   5677       TCP *:https (LISTEN)
httpd      2589 asterisk    3u  IPv4   5674       TCP *:http (LISTEN)
httpd      2589 asterisk    4u  IPv6   5677       TCP *:https (LISTEN)
httpd      2590 asterisk    3u  IPv4   5674       TCP *:http (LISTEN)
httpd      2590 asterisk    4u  IPv6   5677       TCP *:https (LISTEN)
httpd      2591 asterisk    3u  IPv4   5674       TCP *:http (LISTEN)
httpd      2591 asterisk    4u  IPv6   5677       TCP *:https (LISTEN)
httpd      2592 asterisk    3u  IPv4   5674       TCP *:http (LISTEN)
httpd      2592 asterisk    4u  IPv6   5677       TCP *:https (LISTEN)
asterisk  13857 asterisk    7u  IPv4  28003       TCP *:5038 (LISTEN)
asterisk  13857 asterisk    9u  IPv4  28004       TCP localhost:5038->localhost:38022 (ESTABLISHED)
asterisk  13857 asterisk   10u  IPv4  28005       TCP localhost:38021->localhost:mysql (ESTABLISHED)
asterisk  13857 asterisk   11u  IPv4  28010       UDP *:4520
asterisk  13857 asterisk   12u  IPv4  28014       UDP *:5060
asterisk  13857 asterisk   14u  IPv4  28015       UDP 192.168.0.103:4569
asterisk  13857 asterisk   15u  IPv4  28019       UDP *:2727
op_server 13914 asterisk    5u  IPv4  28162       TCP *:4445 (LISTEN)
op_server 13914 asterisk    6u  IPv4  28163       TCP localhost:38022->localhost:5038 (ESTABLISHED)

Nov 8 22:13:04 Packet Filter: ACCEPT UDP packet from [ppp0] 202.148.48.108:4569 to 192.168.0.103:4569

I can even see the packets from tesco’s but as nothing is listerning on asterisk then calls just drop any hints for tracing this ?

bump

Dam I did get this working last night and then this morning I stupidly tried to up move my setting in to FreePABX and now it does not work removing the config in FreePABX and then rewriting the config did not work :frowning:

Changes so far

Add qualify=60 in the [general] of IAX.conf (this fixes the issue where tesco sends the Registration refresh of 0 to Asterisk and cause Asterisk never to update the registration)

Add Trunk info to IAX.conf where 01753XXXXXX is the user name or local phone number that tesco gives out.

[general]
bindport = 4569; Port to bind to (IAX is 4569)
disallow=all
allow=ulaw
allow=alaw
allow=gsm
mailboxdetail=yes
qualify=60
bandwidth=low
diallow=lpc10
jitterbuffer=no
forcejitterbuffer=no
tos=lowdelay
;autokill=yes
#include iax_custom.conf
#include iax_additional.conf

register => 01753XXXXXX:mypassword@gateway.tescointernetphone.com

[01753XXXXXX]
type=friend
context=tesco
auth=md5
username=01753XXXXXX
secret=mypassword
host=gateway.tescointernetphone.com
qualify=no

Add routes to extensions.conf as per Chris example

[macro-outtesco]
exten => s,1,SetCallerID("01753XXXXXX" <01753XXXXXX>)
exten => s,2,Dial(IAX2/01753XXXXXX:mypassword@gateway.tescointernetphone.com/${ARG1},${ARG2},r)
exten => s,3,Congestion

[tesco]
exten => 441753XXXXXX,1,Voicemail(500)


Now I realy dont know what [macro-outtesco] is doing if some one who knows a bit more about Asterisk could tell me what it is doing that would be great.

The [tesco] part should say any call coming in with the DDI of the number in international format (441753XXXXXX) route to extension 500 mailbox

(I was not so sure how to route this to a group or direct to an extension) [color=red](time to read a bit more of voip-info.org and google)[/color]


Connected to Asterisk 1.2.12.1 currently running on pabx (pid = 2572)
Verbosity is at least 1
pabx*CLI>  iax2 show registry
Host                  Username    Perceived             Refresh  State
202.148.48.108:4569   01753XXXXXX  58.106.XXX.XXX:4569         0  Registered
lsof -a -i -u asterisk
asterisk  2572 asterisk   14u  IPv4   6068       UDP 192.168.0.103:4569

pabx*CLI> iax2 show peer 01753XXXXXX
pabx*CLI>

  * Name       : 01753XXXXXX
  Secret       : <Set>
  Context      : tesco
  Mailbox      :
  Dynamic      : No
  Callerid     : "" <>
  Expire       : -1
  ACL          : No
  Addr->IP     : 202.148.48.108 Port 4569
  Defaddr->IP  : 0.0.0.0 Port 0
  Username     : 01753XXXXXX
  Codecs       : 0xff83 (g723|gsm|lpc10|g729|speex|ilbc)
  Codec Order  : (ulaw|alaw|gsm)
  Status       : Unmonitored
 Qualify        : every 60000ms when OK, every 10000ms when UNREACHABLE (sample smoothing Off)
pabx*CLI> iax2 show provisioning
== default ==
Base Templ:   <none>
Username:     <unspecified>
Secret:       <unspecified>
Language:     <unspecified>
Bind Port:    4569
Server:       <unspecified>
Server Port:  4569
Alternate:    <unspecified>
Flags:        register,heartbeat
Format:       ulaw
TOS:          16

Mmmm starting to loose stream at the moment :frowning: any help or ideas about now would be good as every thing looks ok at the moment with the config.

Well I moved from my nice friendly Trixbox install and compiled Aserisk my self and made a small change to chan_iax2.c and now the Tesco connection is working and has been up for the last 12 hours :smile:

So great news :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue:

Its a shame that tescos are sending the refresh 0 causeing Aserisk to not to register but I guess they did not design there system for Aserisk. It looks like the only way to get Tesco working is to make a change to chan_iax2.c

Debuging the standard PC client it looks like it sends a IAX2 ping every few seconds to keep the connection registered and this is hard coded in the client

Well now I have hard coded that in the chan_iax2.c so all is working.

I will create another thread as 1 final question I have is that is it possible to compile the chan_iax2.so by its self as I would like to be able to others who use trixbox to be able to use this custom compiled file on there system.