Monday, August 20, 2012

Working with Asterisk 10 t38 gateway

Below describes my experience with Asterisk 10 t38 gateway.

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:

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                     Generic FAX Applications                 1             Spandsp G.711 and T.38 FAX Technologies  0          

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

t38pt_udptl = yes,redundancy,maxdatagram=400
jbenable = 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.


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.


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. 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.


  2. Thank you very much for your information.
    Australia ETA/eVisitor Visa
    is quiet easy to apply online from Singapore,
    Malaysia, United Kingdom, United States, Canada, France and including all others ETA Eligible Countries from our website.