I'm setting up an Asterisk 1.8 based PBX, and as part of the requirements, I need to make provisions for sending and receiving faxes. The 'big picture' goal is installing a fax printer at each Windows XP (or above) end user computer, and having the user print to it, be prompted for a fax number, and have it email that user back when the send is completed. I also want to be able to receive faxes (sending it to a generic email account).
sip.conf:
[general]
t38pt_udptl=yes
context=from_sip
allowoverlap=no
realm=zzzz.com
udpbindaddr=0.0.0.0
tcpenable=no
tcpbindaddr=0.0.0.0
srvlookup=yes
recordhistory=yes
faxdetect=yes
localnet=192.168.0.0/255.255.0.0
externhost=place.no-ip.com
externrefresh=180
nat=yes
directmedia=no
canreinvite=no
directrtpsetup=no
[callcentric_fax_out]
type=peer
host=callcentric.com
secret=secret
defaultuser=user_num
fromuser=user_num
fromdomain=callcentric.com
nat=yes
canreinvite=no
[callcentric]
type=peer
host=callcentric.com
secret=secret
defaultuser=user_num
fromuser=user_num
fromdomain=callcentric.com
nat=yes
canreinvite=no
callbackextension=s
context=from_cc
insecure=port,invite
;other sip devices below
extensions.conf:
[general]
[globals]
[from_sip]
exten => s,1,Playback(cannot-complete-temp-error)
exten => s,n,Hangup()
[from_cc]
exten => s,1,Answer()
exten => s,n,Ringing()
exten => s,n,Wait(3)
exten => s,n,Authenticate(31337)
exten => s,n,DISA(no-password,from_office)
exten => fax,1,Goto(fax-rx,s,1)
[fax-rx]
exten => s,1,Answer()
exten => s,n,Wait(1)
exten => s,n,Set(FAXFILE=/var/spool/asterisk/fax/${UNIQUEID}.tif)
exten => s,n,ReceiveFAX(${FAXFILE})
exten => h,1,System(/usr/bin/mailfax.sh ${FAXFILE} "${CALLERID(name)}" "${CALLERID(num)}" IncomingFax@domain.com MailFax@domain.com MailFax ${FAXSTATUS})
[hylafax-out]
exten => _1XXXXXXXXXX,1,Gosub(call_via_callcentric_fax_out,${EXTEN},1)
exten => _XXXXXXX,1,Gosub(call_via_callcentric_fax_out,${EXTEN},1)
[call_via_callcentric]
exten => _1XXXXXXXXXX,1,Dial(SIP/${FILTER(0-9,${EXTEN})}@callcentric,30,KTr)
exten => _XXXXXXXXXX,1,Dial(SIP/1${FILTER(0-9,${EXTEN})}@callcentrice,30,KTr)
exten => _XXXXXXX,1,Dial(SIP/1516${FILTER(0-9,${EXTEN})}@callcentric,30,KTr)
[call_via_callcentric_fax_out]
exten => _1XXXXXXXXXX,1,Dial(SIP/${FILTER(0-9,${EXTEN})}@callcentric_fax_out,30,KTr)
exten => _XXXXXXXXXX,1,Dial(SIP/1${FILTER(0-9,${EXTEN})}@callcentrice_fax_out,30,KTr)
exten => _XXXXXXX,1,Dial(SIP/1516${FILTER(0-9,${EXTEN})}@callcentric_fax_out,30,KTr)
[from_office]
exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
exten => 500,n,Dial(IAX2/guest@pbx.digium.com/s@default,TK) ; Call the Asterisk demo
exten => 500,n,Playback(demo-nogo) ; Couldn't connect to the demo site
With this dialplan and SIP setup, I can receive faxes perfectly. I now wanted to use Hylafax and IAXModem to send faxes, which is configured correctly. The incoming context used is [hylafax-out]. Originally, I simply brached to my normal calling context with exten => _1XXXXXXXXXX,1,Gosub(call_via_callcentric,${EXTEN},1)
. Monitoring the Asterisk server with asterisk -rvvvvvv
indeed showed that hylafax was able to place a call via callcentric, but it is at this point that disaster struck. Due to faxdetect=yes in sip.conf, Asterisk detected the fax tone of the receiving machine and jumped to exten => fax,1,Goto(fax-rx,s,1)
. That is, it was recognized that the channel setup to connect to hylafax's channel was part of the [from_cc] context.
To get around this, I duplicated my Callcentric information in sip.conf (callcentric_fax_out) but did not give it a callbackextension. I modified my hylafax-out context to use this new sip peer (which was just a clone of the old, minus the context). This worked perfectly - I could send faxes over this new peer connection, and though asterisk would detect the fax CNG noise, it had nowhere to redirect the call and thus did not interfere. However, it is with this setup that I noticed an issue.
During the call (sending a fax) over the callcentric_fax_out
peer, It seems that incoming calls are rejected on the callcentric
peer. Looking at sip debug, I get this:
<--- SIP read from UDP:204.11.192.35:5060 --->
CANCEL sip:s@69.123.165.187:5060 SIP/2.0
v: SIP/2.0/UDP 204.11.192.35:5060;branch=z9hG4bK-9bf9ce47c01ef721aff04119c7f831ba
f: "WIRELESS" <sip:1516zzzzzzz@66.193.176.35>;tag=3501265591-800738
t: <sip:1516aaaaaaa@ss.callcentric.com>
i: 62793081-3501265591-800709@msw2.telengy.net
CSeq: 1 CANCEL
Max-Forwards: 15
l: 0
<------------->
--- (8 headers 0 lines) ---
<--- Transmitting (NAT) to 204.11.192.35:5060 --->
SIP/2.0 481 Call leg/transaction does not exist
Via: SIP/2.0/UDP 204.11.192.35:5060;branch=z9hG4bK-9bf9ce47c01ef721aff04119c7f831ba;received=204.11.192.35;rport=5060
From: "WIRELESS" <sip:1516zzzzzzz@66.193.176.35>;tag=3501265591-800738
To: <sip:1516aaaaaaa@ss.callcentric.com>;tag=as6091b90b
Call-ID: 62793081-3501265591-800709@msw2.telengy.net
CSeq: 1 CANCEL
Server: Asterisk PBX 1.8.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0
My assumption is that Asterisk gets confused as these peers share an IP.
If anyone has any advice for how I should proceed, it would be much appreciated. Again, my end goal is merely a working Windows Printer to fax gateway, with inbound fax detection working. If you can provide a simpler solution, I am all ears.