Search

Monday, August 20, 2012

Working with Asterisk 10 t38 gateway

Below describes my experience with Asterisk 10 t38 gateway.

Configuration
I am using Hylafax (open-source version 5.2.7) + iaxmodem (1.1.0) + Asterisk 10.7.0 + t38 ISP for oubound fax. 

There are a couple of ways to send t38 faxes to the ISP for PSTN termination, such as Digium's commercial Fax for Asterisk module,  the commercial Hylafax Enterprise Edition or the Asterisk Application SendFAX.  However, these solutions could not support utf8 fax tagline which is one of our primary faxing requirements.

On the other hand, the open-source hylafax not only support utf8 tag line, but also feature fax scheduler and mysql integration for better job management.  The next step is to let Asterisk act as t38 gateway between the iax side and the t38 ISP side.

iax Setup

We would get better result when jitter buffer is disabled in the iaxmodem configurations.

Add 'nojitterbuffer' to /etc/iaxmodem/

Also in the iax2 peer definition in Asterisk, we add:
qualify=no
jitterbuffer=no





Asterisk Setup

We need both Asterisk 10 and spandsp (eg spandsp-0.0.6) for the t38 gateway to work. 

 *CLI> module show like fax
Module                         Description                              Use Count
res_fax.so                     Generic FAX Applications                 1      
res_fax_spandsp.so             Spandsp G.711 and T.38 FAX Technologies  0          

In the sip.conf, we enable t38 on sip call as below.
[general]
t38pt_udptl = yes,redundancy,maxdatagram=400

[t38gw]
type=friend
host=ip
disallow=all
allow=alaw,ulaw
directmedia=no
insecure=port,invite
t38pt_udptl = yes,redundancy,maxdatagram=400
context=mycontext
jbenable = no
qualify=no


To turn on gateway mode, we use the FAXOPT function as below.
exten => _1500.,1,NoOp(${CALLERID(all)})
   same => n,Set(CALLERID(num)=${EXTEN:0:8})
   same => n,Set(FAXOPT(gateway)=yes)
   same => n,Dial(SIP/t38gw/${EXTEN:11:8})


Send the fax


Just before we go ahead, it is better to use a source tiff supported by Asterisk, eg, the one created by ReceiveFAX.

We also need to check the UDPTL ports are opened for t38 traffic.  These ports are defined in /etc/asterisk/udptl.conf.

[general]
udptlstart=4000
udptlend=4999

We start by calling the 'sendfax' hylafax command, passing in the source tiff and required utf8 tagline string.  The selected iaxmodem is then dialed and t30 audio is passed via the iax channel to the t38 partner via Asterisk which acts as t38 gateway.

Troubleshooting

We could get detailed logging of the t38 session with below commands.
sip set debug on
rtp set debug on
udptl set debug on

The log should show the t38 capabilities reported by both sides in a fax session.  One possible reason for failed fax is the incorrect value of t38 datagram.  Note the use of t38pt_udptl = yes,redundancy,maxdatagram=400 to override the datagram value returned by the t38 receiver which incorrectly advertises a tiny datagram value such as 72.

Another problem we might see is the 'RTP read too short' error.  It is worthwhile to check whether we disable jitter buffer along the audio path upon seeing this error .

1 comment:

  1. Thanx a lot for your post, I was strugling to make T38 work, and when I changed t38pt_udptl = yes to t38pt_udptl = yes,redundancy,maxdatagram=400
    everything worked!

    I have a mediatrix connected to my asterisk.

    ReplyDelete