Iaxmodem, hylafax configuration on FreePBX

Problem:

I am unable to have hylafax pick up an incoming call. This is no doubt a simple configuration error. I would appreciate some direction as to which bits to set and how to set them.

Background:

Arch = x86_64
OS = FreePBX-2.11.0beta2.8 (CentOS-6.3) (freepbx)
asterisk = asterisk11-11.3.0-44_centos6 (freepbx)
hylafax = hylafax+.x86_64-5.5.3-1.el6 (epel)
iaxmodem = iaxmodem.x86_64-1.2.0-1.el6 (self packaged)

We automated our fax system in February of 2007 using external modems together with hylafax and avantfax. We are in the process of moving this application, together with its archives and data, to a new server running asterix and using a Digium, Inc. Wildcard TDM410 4-port analog card (rev 11).

Situation:

We have installed and configured asterisk to use devices and users rather than extensions. We have created several users and extensions for both softphones and a soma320. Using these devices we can place and receive calls via the PSTN through asterisk. The fax modem devices and users share the same four digit ids and the devices are configured to use the IP ports that correspond to their device ids (4570/4570/4570 and 4571/4571/4571).

We have installed and configured hylafax+ as required. It is running without problem insofar as we can determine.

We have installed and configured iaxmodem together with two software modems, ttyIAX0 and ttyIAX1 in /etc/iaxmodem. Our /etc/inittab file contains these entries:

<—

send

IA00:2345:respawn:/usr/bin/iaxmodem ttyIAX0

receive

mo00:2345:respawn:/usr/sbin/faxgetty ttyIAX0

send

IA01:2345:respawn:/usr/bin/iaxmodem ttyIAX1

receive

mo01:2345:respawn:/usr/sbin/faxgetty ttyIAX1
—>

Faxgetty is present:

which faxgetty

/usr/sbin/faxgetty

Iaxmodem is running and the two modems are registered:

-- Registered IAX2 '4571' (AUTHENTICATED) at 127.0.0.1:4571
-- Registered IAX2 '4570' (AUTHENTICATED) at 127.0.0.1:4570
   > Saved useragent "snom320/8.7.3.19" for peer 41710

However, when I call in on the POTS line I inevitably get this result in asterisk:

-- Starting simple switch on 'DAHDI/1-1'
-- Executing [s@from-pstn:1] NoOp("DAHDI/1-1", "No DID or CID Match") in new stack
-- Executing [s@from-pstn:2] Answer("DAHDI/1-1", "") in new stack
-- Executing [s@from-pstn:3] Wait("DAHDI/1-1", "2") in new stack
-- Executing [s@from-pstn:4] Playback("DAHDI/1-1", "ss-noservice") in new stack
-- <DAHDI/1-1> Playing 'ss-noservice.ulaw' (language 'en')

As far as I know I am not matching on either CID or DID for anything and I am unsure as to how I should proceed to route incoming fax calls through asterisk so that hylafax gets them but still route incoming voice calls so that the ring-group gets those. The intent is that for now the PSTN lines will handle both incoming and outgoing faxes and voice traffic routed through asterisk. In production we plan to have two ports dedicated to fax traffic and six to voice traffic (which I realize will require an additional 4-port FXO card).

What must I do in freePBX to accomplish this and how do I do it?

In your inbound route there is a “detect fax” option, it is pretty self explanatory. But you will need a “pseudo DID” using from-zaptel (do that in the context line(s) in /etc/dahdi/system.conf) and an inbound route defined for each of your FXO’s. You can use the same one for all trunks if you want. There is a page called “ZAP Channel DID’s” that makes the DID bit easier, it mentions zapata.conf but that is very old, this should be the system.conf file previously noted ,

If you use the iaxmodem init script you should probably allow that to start your iaxmodems and take them out of inittab.

If you do that and you can send a fax to 4571 and it’s associated DID from ttyIAX0 within Avantfax and get much the same result, you are pretty well there

You need to have your DAHDI channels in the from-pstn context and have a “catch all” any did/any cid route to your ring group.

How are you going to detect fax calls for routing to IAXMODEM?

Isn’t this an awful lot of trouble when FreePBX includes a perfectly functioning fax gateway?

Thank you for your suggestions.

Presently we employ separate dedicated fax lines in a telco hunt group connected to external modems for incoming and outgoing faxes. The voice lines go through a Comdial digital pbx. It is intended that eventually FreePBX will replace both systems.

In the trial period I intend to pick specific incoming FXO channels (individual telephone line numbers) to route as faxes and all others to route as voice. That is what I am attempting to accomplish right now.

I infer from the documentation that I can specify certain channels to wait for a fax signal and then route calls to the IAXmodem ring-group if detected and to the default ring-group otherwise. That will likely be the behaviour selected for the production environment so that misdialled fax calls can still be received. All outgoing faxes will still use the dedicated lines although that might not be necessary once everything is set up properly.

I am presently trying to figure out how to configure the inbound and outbound routes, again. In the process of experimentation I have set up and torn down the entire system at least twice and performed numerous changes that I later reversed; and sometimes reapplied. Consequently I sometimes confuse which steps I have already taken in this iteration and which I did in a previous one but have not yet in the present.  That appears to be part of the cause of my current frustrations.

Isn't this an awful lot of trouble when FreePBX includes a perfectly functioning fax gateway?

Functioning is not the same thing as useful.  Our business requires searchable and retrievable archives of all business related written communications. We use web based interfaces for faxing and email (and hopefully telephone in the near future) so that our telecommuters do not have to deal with systems and interfaces different from those employed in the office when they are working from remote locations. We also use multiple dedicated fax lines. I see nothing in the FreePBX documentation respecting fax which indicates to me that any of these requirements are met.

On the other hand we have used Hylafax with Avantfax successfully to provide all this and much more since 2007. I am sure that there are more elaborate solutions possible with FreePBX then the simple fax to email gateway I have read about.  However, it seems to me that getting FreePBX to interface with Hylafax through IAXModem (which was written for that purpose) is likely less onerous then converting six years of archives to an entirely new system and having to implement that across the company.

Thanks again.

I took your recommendation but I am having trouble mapping what you are writing with what I am dealing with. In the FreePBX that I am using I cannot find any reference to ZapTel. I have read that Dahdi is the replacement term but even allowing for that I cannot find any page referring to Channel DID’s.

Presently I am trying to just get the iaxmodem to pick up so I am dialling the line from a handset, no fax tone is being generated by the caller. I recognize that the DID (Direct Inward Dialling?) setting is crucial to getting this to work but I cannot seem to locate where this should be set.

The contents of my /etc/dahdi/system.conf file indicate that I should not place anything therein manually as it will eventually be removed by a system change.

cat /etc/dahdi/system.conf

Autogenerated by /usr/sbin/dahdi_genconf on Mon Apr 8 10:13:22 2013

If you edit this file and execute /usr/sbin/dahdi_genconf again,

your manual changes will be LOST.

Dahdi Configuration File

This file is parsed by the Dahdi Configurator, dahdi_cfg

Span 1: WCTDM/0 “Wildcard TDM410P” (MASTER)

fxsks=1
echocanceller=oslec,1
fxsks=2
echocanceller=oslec,2
fxsks=3
echocanceller=oslec,3
fxsks=4
echocanceller=oslec,4

Global data

loadzone = us
defaultzone = us

I had already set a DID on an input form called DAHDI Channel DIDs from the Connectivity dropdown menu.

Edit DAHDI Channel: 1

DAHDI Channel DIDs allow you to assign a DID to specific DAHDI Channels. You can supply the same DID to multiple channels. This would be a common scenario if you have multiple POTS lines that are on a hunt group from your provider. You MUST assign the channel’s context to from-analog for these settings to have effect. It will be a line that looks like:

context = from-analog

in your chan_dahdi.conf configuration effecting the specified channel(s). Once you have assigned DIDs you can use standard Inbound Routes with the specified DIDs to route your calls.
Edit Channel: 1
Description: Fax Line
DID: 9055610757

Then on the Inbound Routes form from the same drop down menu I have this:

Route: Fax Transmissions

Delete Route Fax Transmissions

Edit Incoming Route
Description?: Fax Transmissions
DID Number?: 9055610757
CallerID Number?:
CID Priority Route?:
Alert Info?:
CID name prefix?: FAX
Music On Hold?: None
Signal RINGING?:
Pause Before Answer?:
Privacy Manager?: No
Source?: None
Detect Faxes?: No
Call Recording?: No
Language?:
Set Destination
Ring Groups -> “Brockley Incoming Faxes <457>”

And Ring group 457 is defined as:

Ring Group: 457

Used as Destination by 1 Object:

Edit Ring Group

Group Description:? Brockley Incoming Faxes
Ring Strategy: ? Hunt
Ring Time (max 300 sec) ? 15
Extension List:? 4570 4571

Announcement: None
Play Music On Hold? Ring
CID Name Prefix:
Alert Info?:
Ignore CF Settings?:
Skip Busy Agent?:
Enable Call Pickup?:
Confirm Calls?:
Remote Announce: Default
Too-Late Announce: Default

Change External CID Configuration
Mode: Default
Fixed CID Value:
Record Calls?: Never

Destination if no answer: Terminate Call -> Hangup

My apologies. I was looking at a FreePBX 1.10 fax server,I see that you are using a later version so do what it says :slight_smile:

you still don’t have fax detect turned on in your inbound route choose your ringGroup as the destination for a DAHDI detected fax. Use the normal destination for voice calls, if you don’t expect voice calls then your setup should work.

BUT, the iaxmodems do not answer the phone, hylafax does (faxgetty), the iaxmodems need to be “attached” to hylafax via files

/var/spool/hylafax/etc/config.ttyIAX0
/var/spool/hylafax/etc/config.ttyIAX1

etc. (there is an example config.ttyIAX in the iaxmodem source)

hylafax needs to be restarted to load them and when it is working then

faxstat -v

will show something like:-

Trying localhost [2] (127.0.0.1) at port 4559…
Connected to your.box.com.
220 your.box.com server (HylaFAX ™ Version 5.5.2) ready.
-> USER root
230 User root logged in.
-> MDMFMT
200 Modem %m (%n): %s
-> EPRT |1|127.0.0.1|49004|
200 EPRT command successful.
-> LIST status
150 Opening new data connection for “status”.
HylaFAX scheduler on your.box.com Running
Modem ttyIAX0 (+1.323.555.1212): Running and idle
Modem ttyIAX1 (+1.323.555.1213): Running and idle

As an aside, asterisk/dahdi turns off echo cancellation when a fax is detected so oslec which does a great job for voice is not in play don’t forget to run fxotune -i and adjust rx/txgain if necessary to optimize the FXO ports to get the least errors in your faxes.

I had previously set up the conf.ttyIAXn files in /var/spool/hylafax/etc following the instructions in the iaxmodem README file These are:

. . .
** USING IAX MODEM **

Once IAXmodem is running you are ready to use it with your application.

If your application is HylaFAX, there is a HylaFAX modem configuration
file included with IAXmodem (config.ttyIAX). The config file is for
HylaFAX version 4.2.2 and later. Instead of running faxaddmodem,
simply edit this config file to your liking and then copy it to
/var/spool/hylafax/etc/. (Run faxgetty and the rest of HylaFAX as
usual.)
. . .

# ll /var/spool/hylafax/etc/config.ttyIAX* -rw-r--r-- 1 uucp uucp 2471 Apr 15 13:53 /var/spool/hylafax/etc/config.ttyIAX0 -rw-r--r-- 1 uucp uucp 2471 Apr 15 13:53 /var/spool/hylafax/etc/config.ttyIAX1

faxstat -v shows this:

# faxstat -v Trying localhost [10] (::1) at port 4559... Trying localhost [2] (127.0.0.1) at port 4559... Connected to (null). 220 voinet01.hamilton.harte-lyne.ca server (HylaFAX (tm) Version 5.5.3) ready. -> USER root 230 User root logged in. -> MDMFMT 200 Modem %m (%n): %s -> EPRT |1|127.0.0.1|39127| 200 EPRT command successful. -> LIST status 150 Opening new data connection for "status". HylaFAX scheduler on voinet01.hamilton.harte-lyne.ca: Running 226 Transfer complete.

Which indicates that as you suspected, the iaxmodems are not running. My /var/spool/hylafax/etc/config file contains this:

LogFacility: daemon CountryCode: 1 AreaCode: 905 LongDistancePrefix: 1 InternationalPrefix: 011 DialStringRules: etc/dialrules ServerTracing: 1 MaxDials: 6 #ModemGroup: /dev/ttyIAX

My /var/spool/hylafax/etc/config.ttyIAX0 file contains this:

# cat /var/spool/hylafax/etc/config.ttyIAX0 CountryCode: 1 AreaCode: 905 FAXNumber: +1.905.561.0757 LongDistancePrefix: 1 InternationalPrefix: 011 DialStringRules: etc/dialrules ServerTracing: 0xFFF SessionTracing: 0xFFF RecvFileMode: 0600 LogFileMode: 0600 DeviceMode: 0600 RingsBeforeAnswer: 1 SpeakerVolume: off GettyArgs: "-h %l dx_%s" LocalIdentifier: "Harte & Lyne - IAXmodem" #TagLineFont: etc/LiberationSans-25.pcf TagLineFont: etc/lutRS18.pcf TagLineFormat: "From %%l|%c|Page %%P of %%T" MaxRecvPages: 200 # # # Modem-related stuff: should reflect modem command interface # and hardware connection/cabling (e.g. flow control). # ModemType: Class1 # use this to supply a hint

Enabling this will use the hfaxd-protocol to set Caller*ID

#ModemSetOriginCmd: AT+VSID="%s","%d"

If “glare” during initialization becomes a problem then take

the modem off-hook during initialization, and then place it

back on-hook when done.

#ModemResetCmds: “ATH1\nAT+VCID=1” # enables CallID display
#ModemReadyCmds: ATH0

Class1AdaptRecvCmd: AT+FAR=1
Class1TMConnectDelay: 400 # counteract quick CONNECT response

If you have trouble with V.17 receiving or sending,

you may want to enable one of these, respectively.

#Class1RMQueryCmd: “!24,48,72,96” # enable this to disable V.17 receiving
#Class1TMQueryCmd: “!24,48,72,96” # enable this to disable V.17 sending

You’ll likely want Caller*ID display (also displays DID) enabled.

ModemResetCmds: AT+VCID=1 # enables CallID display

The pty does not support changing parity.

PagerTTYParity: none

If you are “missing” Caller*ID data on some calls (but not all)

and if you do not have adequate glare protection you may want to

not answer based on RINGs, but rather enable the CallIDAnswerLength

for NDID, disable AT+VCID=1 and do this:

#RingsBeforeAnswer: 0
#ModemRingResponse: AT+VRID=1

Uncomment DATE and TIME if you really want them, but you probably don’t.

#CallIDPattern: “DATE=”
#CallIDPattern: "TIME="
CallIDPattern: "NMBR="
CallIDPattern: "NAME="
CallIDPattern: “ANID=”
#CallIDPattern: “USER=” # username provided by call
#CallIDPattern: “PASS=” # password provided by call
#CallIDPattern: “CDID=” # DID context in call
CallIDPattern: “NDID=”
#CallIDAnswerLength: 4

Should I take this up on the hylafax+ list or is there something obvious that I have done incorrectly?

I note a difference in behaviour between faxstat run on the new freepbx host and the output from the faxstat run on our existing fax server. This variance is quite likely the result of different versions of hylafax but I present it here in case it proves significant.

First however, I determined that hylafax is indeed running on the freepbx host and listening on port 4559.

telnet 192.168.6.122 4559

Trying 192.168.6.122…
Connected to voinet01.hamilton.harte-lyne.ca (192.168.6.122).
Escape character is ‘^]’.
220 voinet01.hamilton.harte-lyne.ca server (HylaFAX ™ Version 5.5.3) ready.

Nonetheless, faxstat -v reports this on the existing fax server:

faxstat -v

Trying localhost (127.0.0.1) at port 4559…
Connected to localhost.localdomain.
220 fxsrv.harte-lyne.ca server (HylaFAX ™ Version 4.4.3) ready.
-> USER root
230 User root logged in.
-> PORT 127,0,0,1,216,15
200 PORT command successful.
-> LIST status
150 Opening new data connection for “status”.
HylaFAX scheduler on inet01.hamilton.harte-lyne.ca: Running
Modem ttyS0 (+1 905 561 0757): Running and idle
Modem ttyS1 (+1 905 561 0757): Running and idle
226 Transfer complete.

But on the freepbx system I see this:

faxstat -v
Trying localhost [10] (::1) at port 4559…
Trying localhost [2] (127.0.0.1) at port 4559…
Connected to (null).
220 voinet01.hamilton.harte-lyne.ca server (HylaFAX ™ Version 5.5.3) ready.
-> USER root
230 User root logged in.
-> MDMFMT
200 Modem %m (%n): %s
-> EPRT |1|127.0.0.1|46981|
200 EPRT command successful.
-> LIST status
150 Opening new data connection for “status”.
HylaFAX scheduler on voinet01.hamilton.harte-lyne.ca: Running
226 Transfer complete.

The connected to (null) statement is what bothers me.

I discover that the problem has something to do with inittab (probably some artefact of the el6 switch to upstart) and that if I run faxgetty from the command line then I gan get the iax modems up:

# faxgetty -D ttyIAX0 # faxgetty -D ttyIAX1 # # ps -ef | grep ttyIAX uucp 4324 1 0 15:55 ? 00:00:03 faxgetty -D ttyIAX0 uucp 4490 1 0 16:02 ? 00:00:00 faxgetty -D ttyIAX1 root 4492 32407 0 16:02 pts/4 00:00:00 grep ttyIAX

faxstat -v

Trying localhost [10] (::1) at port 4559…
Trying localhost [2] (127.0.0.1) at port 4559…
Connected to (null).
220 voinet01.hamilton.harte-lyne.ca server (HylaFAX ™ Version 5.5.3) ready.
-> USER root
230 User root logged in.
-> MDMFMT
200 Modem %m (%n): %s
-> EPRT |1|127.0.0.1|52880|
200 EPRT command successful.
-> LIST status
150 Opening new data connection for “status”.
HylaFAX scheduler on voinet01.hamilton.harte-lyne.ca: Running
Modem ttyIAX0 (+1.905.561.0757): Running and idle
Modem ttyIAX1 (+1.905.561.0757): Running and idle
226 Transfer complete.

However, I still cannot get hylafax to pick up when I dial in on the test line.

This is what asterisk reports: Asterisk (Ver. 11.3.0): Peers Sip Peers Name/username Host Dyn Forcerport ACL Port Status 41710/41710 192.168.6.71 D A 2048 OK (22 ms) 41711 (Unspecified) D A 0 UNKNOWN 41712 (Unspecified) D A 0 UNKNOWN 41713 (Unspecified) D A 0 UNKNOWN 41714 (Unspecified) D A 0 UNKNOWN 41715 (Unspecified) D A 0 UNKNOWN 41716 (Unspecified) D A 0 UNKNOWN 41717 (Unspecified) D A 0 UNKNOWN 90012 (Unspecified) D A 0 UNKNOWN 9 sip peers [Monitored: 1 online, 8 offline Unmonitored: 0 online, 0 offline] IAX2 Peers Name/Username Host Mask Port Status 4571 127.0.0.1 (D) 255.255.255.255 4571 OK (3 ms) 4570 127.0.0.1 (D) 255.255.255.255 4570 OK (1 ms) 2 iax2 peers [2 online, 0 offline, 0 unmonitored]

Hylafax says it is online and working

watch faxstat

if you stop and start iaxmodem it should so reflect, while you make a fax call you should see it answer if not then check your work as I can assure you that it does work. if there is no action then the call is not getting to hylafax,

when you dial the extension from a regular intercom line does it answer ? If not…you will need to do a bit more work on the hylafax part.

Here is a links to help you with upstart:
http://www.weezey.com/2012/06/upstart-replaces-system-v-init-in-centos-6/

I know it works as I had it working a couple of months ago. (iaxmodem, hylafax, avantfax)

I have developed the following scripts to handle startup of iaxmodem and faxgetty using upstart. This is a side issue really but as RHEL6 has switched to upstart, and RHEL7 apparently is switching to systemd, most of the recipes on the net are out of date in this critical area. So, I am posting these here for others that find themselves in a similar situation. There are three files all in /etc/init. Only one is automatically started. The other two exist solely to provide respawn capability to each instance.

—>

/etc/init/LOCAL-iaxmodem-faxgetty.conf – upstart faxgetty control

This service maintains a faxgetty for each sepcified device.

It is started from the LOCAL-iaxmodem-faxgetty-start.conf init script.

Setup script configuration variables:

Note that env stanzas do not invoke shell expansion so one may

not include previously defined env keys with later ones using the

$key idiom and obtain the anticipated result.

env BIN_FAXGETTY=/usr/sbin/faxgetty

stop on runlevel [016]
respawn

instance $TTY
exec ${BIN_FAXGETTY} $TTY

<—
—>

/etc/init/LOCAL-iaxmodem–iaxmodem.conf - upstart iaxmodem control

This service maintains an iaxmodem on the specified device.

It is started from the LOCAL-iaxmodem-faxgetty-start.conf init script.

Setup script configuration variables:

Note that env stanzas do not invoke shell expansion so one may

not include previously defined env keys with later ones using the

$key idiom and obtain the anticipated result.

env BIN_IAXMODEM=/usr/bin/iaxmodem

stop on runlevel [016]
respawn

instance $TTY
exec ${BIN_IAXMODEM} $TTY

<—
—>

/etc/init/LOCAL-iaxmodem-faxgetty-start.conf - upstart iaxmodem &

faxgetty start

usage “Starts iaxmodem and faxgetty for each ttyIAX file in
/etc/iaxmodem”

Uses /etc/LOCAL-init/iaxmodem-faxgetty.conf and

/etc/init/LOCAL-iaxmodem-iaxmodem.conf

Starts each init script for each ttyIAX* file placed in /etc/iaxmodem.

Separate instances are required so that init respawn will work on each

pseudo modem device.

Run if upstart rc has ended (stopped) and run level is . . .

start on stopped rc RUNLEVEL=[2345]

Setup script configuration variables:

Note that env stanzas do not invoke shell expansion so one may

not include previously defined env keys with later ones using the

$key idiom and obtain the anticipated result.

env BIN_IAXMODEM=/usr/bin/iaxmodem
env ETC_IAXMODEMS=/etc/iaxmodem/ttyIAX*

task
script
for ttyIAX in ${ETC_IAXMODEMS} ; do
initctl start LOCAL-iaxmodem-faxgetty TTY=$(basename $ttyIAX)
initctl start LOCAL-iaxmodem-iaxmodem TTY=$(basename $ttyIAX)
done
end script
—<

Now, back to asterisk. . .

Good work, I personally don’t use Centos, I use Debian 7, so don’t have that problem (yet :wink: ) .

I discovered that my problem is the lack of a DID provided by the incoming call. I am not familiar with telco (Bell Canada) practices, services and terms so I have no idea if DID strings are a standard service (evidently not), a paid-for optional service, an free optional service which needs to be turned on line by line, even if available at all on analogue lines, or something else.

In any case, creating a default route with no CID or DID and enabling fax detection resolved my problems and I can send and receive faxes. Now I have a different issue, but for that I will create a new topic.

The DID of a standard analog line is intrinsic in it’s own existence, it is it’s phone number!!. That is why you need to assign a pseudo-DID to route calls from a particular FXO.