FreePBX 2.6, NVFax Detection, Asterisk 1.6.1.6 and Digium FAX - Working!

Yes, I am using FFA, but with FreePBX you have two choices on FAX detection on incoming calls if you are doing silent detection - i.e. listening for CNG tones on a call to determine if it is a FAX call - Zaptel and NVFax. Obviously Zaptel will not work with 1.6 - there is no Zaptel, only Dahdi. So if you want one-number setups for people on their DID’s being able to receive FAX and Voice on the same number, you need to listen for faxes - hence the NVFax detection.

This is one of the more key features of using FreePBX and our customers are crazy about it - it has been (until now) holding us back from adopting 1.6.x - and we really want to get going with 1.6.x!

Greg

This information is difficult to come by. I’ve been playing w/ Asterisk cvs versions and everything else w/ an SPA2102 SPA w/ the latest 5.2.10 firmware. I have outbound and inbound faxes working 80-90% of the time via pass-through T.38. This works for a hobbyist, but not a business. So here’s my question. Is it possible to utilize the NV fax detect and the free asterisk plugin from digium to do pass-through? Right now my pass-through method works ok, but we need something better. The documentation from Digium looks like that module only works for termination and origination locally on the server; not pass-through or relay.

It seems that the closest thing out there for 100% is the AS5300 cisco w/ the SPA2102 w/ the proper configuration. There is a number I cannot ever fax to, but a regular landline works. I’ve tried asterisk 1.4.26, 1.6.0.10, 1.6.2-svn. Even though many T.38 improvements have been made, I think at this time the issue is more around fax tone detections w/ some strange fax machines. I’m not seeing the problem w/ T.38. I bet it’s something in the DSP modules in terms of detection problems. I’m using the latest from the SPANDSP site too.

I am looking forward to discussing this stuff w/ anyone who has a serious interest in this. I’m the Veep for a technology company and having FoIP is becoming more critical to the business model. My e-mail - brock (at)digitalpath.net

I am looking for a FoIP solution that will be 99% or better. Not 80-90%.

Thanks

Brock

I am talking about the built-in Digium app_fax.c. You can select to build it under ‘make menuselect’ -> applications -> app_fax, but it requires you have compiled and installed spandsp. This adds the SendFax and ReceiveFax applications to asterisk. I have done some testing with them and they seem to work as well as the old newman fax apps.

As far as I know these don’t have any limit on the number of faxes and even have some t.38 support in them.

You know, it would be funny if it wasn’t so annoying - I HATE FAX and yet it consumes probably 80% of my development time and 90% of my troubleshooting time for customers - people just will not let FAXing go no matter how many times you show them Scan-2-E-Mail - have I mentioned how much I HATE FAX!

That being said, T.38 is the solution for fax once it is properly implemented, I am just working on figuring out how to translate this into FreePBX and make it a workable solution for my customers.

For the record, here is what I have found works:

  1. Outside-World to Asterisk - Inbound Reception: FAXes from the outside world coming in on a TRUE TDM PRI and received by Asterisk work 100% of the time - no adjustments on the sending machines, and no adjustments on the receiving machine - it just works. I have 100% success with Asterisk 1.4.26.2 and the current version of agx-ast-addons and spandsp-0.0.6pre12. I also have 100% success with Asterisk 1.6.1.8 and FAX-For-Asterisk from Digium with the modified app_nf_faxdetect.c and app_nv_backgrounddetect.c that I reference above. I also have had 100% success on the above configurations with SIP trunks from Paetec (formerly McLeod) delivered on a MPLS T1 (it’s what we use in our office). I have had less than 90% with other SIP trunking providers, but I don’t think it was their fault since I was getting them over the open Internet, and I don’t think that is a fair comparison.

  2. FAX Machines connected to Digium Hardware FXS Ports sending over TDM PRI - The only adjustment I have found that needed to be done was to turn off ECM - then this became a 100% proposition, but only with ECM turned off, and only on a TDM PRI.

  3. FAX Machines connected to cheap ATA (Grandstream) sending over TDM PRI - in this case, I have to turn off ECM and also slow the machine down to 14.4 or less - sometimes even 9.6K - but if I slow the machine down enough, it works 100% of the time - I think the weakness is with the Grandstreams.

  4. FAX Machines connected to Digium Hardware FXS Ports sending over SIP Trunks - Mixed Bag - sending to remote fax machines seems to work fine with ECM turned off, but to round-robin send to myself (people start using FAX-2-E-Mail as a Scanner!) you have to turn off ECM and slow the machine WAY down - 14.4K Max, 9.6K is more reliable - which makes faxing long documents SLOW.

  5. FAX Machines connected to cheap ATA (Grandstream) sending over SIP Trunks - I have had no luck making this work at all - period.

Now, as I understand it (and I admit, I may be missing LOTS here) T.38 on the ATA’s will allow a FAX machine to talk directly to the FAX machine and convert the FAX to a T.38 transmission (100% reliably) and then pass this stream to FAX-For-Asterisk which then (again 100% reliably) converts this to a TDM signal on your trunk of Choice (PRI or POTS) and transmits the FAX (reliably again!). If you are using a SIP trunking provider that supports T.38, then they are supposed to take the T.38 stream from you (again, supposedly 100% reliably) and their Border Session Controllers/Gateway Devices are supposed to reconstitute this into a TDM FAX again when it leaves their equipment and hits the PSTN - that’s the theory as I understand it anyway.

Has anyone tried a range of ATA’s and found one better than another? - we have tried the Cisco 186’s and the Grandstreams - the Grandstreams seem to work fine with TDM PRI’s, but we are doing 90% SIP Trunking now, and we need a reliable ATA - or we need to get the T.38 going and test the claims that T.38 works on these devices - I HATE FAX!

Greg

Sorry if I’m too “grumpy” for you, but I hate to see someone doing things wrong, and you are — you should NEVER edit a file that is “owned” by FreePBX, and I was just trying to say that you don’t have to do that — there are ways to accomplish what you need to do without editing files owned by FreePBX. Of course, it’s your system, so if you want to “break the rules” you can do so, but I would hate to see anyone else follow your lead.

Although I don’t have any trunks from Bandwidth.com, I have a really hard time believing that the “proud sponsor of FreePBX” (to quote the small ad that is staring me in the face as I type this) would force you to do something that is totally against good practice — that really doesn’t make sense to me. Maybe, instead of asking for help with faxing, you should have first asked how to set up a trunk for Bandwidth.com, and someone might have been able to help you with that.

And by the way, I’m quite familiar with having to strip a + from the incoming CallerID using a small bit of custom context (although I think that now, either of the third party modules Set CallerID or Caller ID Superfecta can also handle this — and yes, FreePBX probably should deal with the leading + gracefully, without the need of third-party modules). But after stripping the leading +, you can still send your calls to from-trunk rather than some other context.

Anyway, do what you want, but when someone’s trying to explain to you that you are doing it wrong (without trying to make you look bad in the process) you might want to pay heed, because playing with FreePBX’s “owned” files is very likely to come back and bite you (or your company, if you’re doing this for a company) in the butt in the future. What if you get sick and someone else has to make changes on the system? That’s all I’m saying.

Paul Adams: I have a public FTP server at ftp://ftp.bdc-llc.com/sources-1.6 that has all the files I used to get this working - you are free to take any that you need - I have wanted to play with Hylafax, but I needed to get reception going and I wanted to try the FAX-For-Asterisk - rrb3942 pointed out that maybe the built-in app_fax would receive - I will try this as soon as I can and post the results.

Also, in case somebody reads this thread and get’s misled:

Bandwidth.com seems to now support trunks that register - this would eliminate the need to replace the from-sip-external for the inbound context - the last Bandwidth.com trunks I installed were about 18 months ago, and it looks like they do them correctly now - also, the Inbound Routes in FreePBX now accept a + in the string to match - I don’t know when that changed, but as they say the proof is in the doing. Your inbound context should still strip the + out of the DID and the Caller ID - the phones don’t like it for things like redial.

As to the template file for extensions.conf, from what I can figure out it is only written when FreePBX is installed, so the modification seems to be safe - I can’t find a template file anywhere on my system that rewrites the file, but I may be missing something - the modification is necessary to get FAX-For-Asterisk working with FreePBX right now.

GSnover: Followed your comments to place the 2 NV fax C files in the relevant apps directory - recompiled & reinstalled Asterisk. Changed my dialplan to use NVFaxDetect - worked perfectly! Thanks for the amended NV fax files.

As a comment - I ‘think’ you could do what I’m trying to do using the built-in app-fax (detect then receive, send to the right user depending on incoming DID).

Also - Hylafax is easy when it comes to sending - free desktop Windows fax printing clients makes it easy for my users to send AND Hylafax e-mails the sender an update letting them know it was sent OK.

I’m sure if you are clever with dialplan’s & external commands - you could make all this happen within Asterisk / FreePBX - but I’m not, so I use Hylafax…

If you ever want some Hylafax pointers - just ask…

Thanks again,

Paul Adams

If you install spandsp (http://www.soft-switch.org/) you should be able to compile asterisk 1.6+ with the fax applications (SendFAX and ReceiveFAX) and not need the digium fax app.

That makes no sense at all. The context is whatever you set it to be in your trunk configuration, so if you blindly follow someone else’s setup instructions and set the context to from-bandwidth or from-sip-external, then of course it will not work without hacking the code. Instead, use context=from-trunk and it will work without hacking the code.

Now, if you are bringing calls in without going through a trunk, then all bets are off - but even then, you have to set the context somehow, so use from-trunk as your context.

rrb3942 - Are you talking about the built-in Digium app_fax.c? Or the old Newman FAX application? Because the applications that come with agx-ast-addons won’t compile with 1.6 - I have tried and tried - but I am completely willing to believe that I am the weak link in that equation - my C++ skills are a little rusty…

wiseoldowl - that was kind of a grumpy response, but here is my response anyway - inbound traffic from Bandwidth.com comes in E.264 format - +15053430650 - leading +, country code, and then NPA and NXX - FreePBX chokes on that, so you HAVE to send the incoming traffic to a custom context to strip that + before you then pass on the resultant DID for processing - and Bandwidth.com does NOT support trunks registration - they just hose the traffic at the IP address that you tell them to, and it is up to you to process it on your end. Trunks that register would fix this problem, but repeated pleas to Bandwidth.com have gone unanswered. And no, I am not blindly following anybody’s instructions - I had to figure it out for myself because the existing instructions didn’t work!

Greg

GSnover - you are right - info on this is difficult to come by.

I’ve got Asterisk 1.6.1.6, iaxmodem & hylafax all working on the same CentOS 5.4 box.

I’d like to offer my users voice / fax service on their regular numbers - so I need to detect incoming faxes. I was Googling & found your posts…

I believe I just need NV Fax Detect & SPandSP to make this work - with detected faxes going out to the iaxmodem…

Eventually - I’d like to past the DID to hylafax as well so the faxes get routed to the right people - but I’m just trying to get detection working at the moment.

I would apprieciate any advice you could give…

Regards

Paul Adams

Alright, it seems like it worked - however, it was SLOW and it was only one page - it you want to try, here are a couple of suggestions:

  1. I deleted extension 5487 and created extension 5059985487 - in looking at a sip debug, it showed that the function was actually passing my extension in the outbound SIP header - I figured that was what it was failing on, and on a hunch, switched it to the fully qualified number as my extension and wha-lah! Outbound calls were now working. This was necessary for my SIP trunk - you may have to get creative with your trunks. The function seems to pull the information from the device definition (we are in DeviceAndUser mode) so that answers my previous question.

  2. Use a good ATA - While I was able to send the FAX, it was SLOW and it took a long time to sync-up - I don’t know what the cause is, but I will have an SPA2102 here in a couple of days - this test was done with a GrandStream HandyTone-286 and I just don’t trust it for this test. The first couple of times, the FAX failed, so I am still figuring out what is what.

That’s it for tonight - more tomorrow!

Greg

I’m fortunate that I currently number extensions w/ the area code. It just makes the whole DID and long distance logic easier in our setup.

So… my understanding says that this should then behave in the following manner-

ATA sends fax to sip server; sip server recognizes the call as a fax and sends a re-invite to the ATA to start T.38.

The way this would have previously worked is the following w/ just pass-through:

ATA sends fax to sip server, sip server sends message over sip trunk to carrier, carrier detects T.38 and sends re-invite back to sip server, sip server sends re-invite back to T.38 capable ATA to start transmission.

In a pure SIP to SIP trunk environment (where the provider connects over a SIP trunk) - is there any advantage of having T.38 gateway support? I’m guessing that if we had a PRI coming into a digium or sangoma card then the asterisk box would just act like the carrier machine in my setup. Hopefully faxing would be near 100% reliability with this method.

BTW, I can send you a screenshot of my SPA2102 config screen in PDF when you get that box in-stock. this will save you lots of time tinkering.

I’m in the office tomorrow Greg. Feel free to call me. I might be busy in the morning but it would be good to touch base with you on this.

Brock
530-571-7520

Here is what I found on Wikipedia:

Which show’s a diagram of how T.38 is supposed to work. It also agrees conceptually with what I thought T.38 should do.

For someone reading this after the fact, here is what I have tested, and what I am trying to “Fix”:

FAX just will not go away - therefore our Asterisk systems must allow FAX machines to be connected and function. With earlier versions of Asterisk, we were primarily connecting to TDM PRI’s and in those situations, ATA’s worked fine with an Analog FAX machine connected to them.

Now, we have switched to SIP trunking, and the ATA’s that we had been using (Grandstream HandyTone 286 and 386) don’t seem to work at all. We have had success with Digium Hardware FXS ports (Mostly TDM410b’s) but it is MUCH more convenient to just pop an ATA next to where the FAX machine is and use that - to use Digium Hardware, we must have a Home-Run back to the box - not very handy at a lot of sites.

T.38 is supposed to give reliable FoIP - therefore that is what we are trying to make work.

More test results to follow!

Greg

Did you make any further progress on this? I’m thinking the T.38 gateway would also work great between sip to sip trunks. Local extensions who want to use T.38 to each other won’t work properly w/o a gateway.

Well, I have made some progress, but I also had to back up a bit -

First, I got my SPA2102 in this afternoon, and I decided to try something that I know the Grandstream’s fail miserably on - Analog FAX machine attached to ATA on a SIP Extension sending a FAX out on our SIP trunk - guess what - it works PERFECTLY!!! This is Analog Transmission in the RTP Audio Packets, not T.38 - and it still works perfectly!

Aughhhhhh - I can’t believe how much time I have wasted trying to get those dang Grandstreams going, and thinking that it was Asterisk and our SIP trunks that were the problem - it was the Grandstreams! All right, fool me once shame on you, fool me twice, shame on me! Never again anything Grandstream! If anybody is interested in a bunch of HT-286, 386, and 503’s let me know - you can have them CHEAP!

So, that is a Game-Changer for us - this SPA2102 works perfectly - I am at my house, so not only does it work, it works going from Comcast (No QOS at my house) to Paetec (QOS) out through the PSTN to remote FAX Machines - I have sent 15 FAXes so far, each at least 3 pages, loaded with graphics and some as long as 10 pages, and they all came in right the first time - I can even fax to myself - the only way I have ever been able to make that work was with Digium Hardware FXS ports in the box itself - Dang! Hope someone else finds this post and doesn’t have to waste all the time that I have on these Grandstreams - Avoid them like the Plague!

Now the bad (sort of - I think I know what’s wrong) news:

Monday, when I got to work, I still had Asterisk 1.6.2.0.rc4 up with the T.38 Gateway patch installed and I thought I had tested every scenario over the weekend, but I missed one - Remote Analog FAX trying to be received by Asterisk as an inbound FAX-2-EMail - Problem is that because our trunk is SIP, when the FAX detection saw CNG, it worked correctly in shifting to FAX reception mode, but it then (Because, I think, our trunk is SIP) It tried shifting the reception into T.38 which of course caused Paetec to immediately say “No Way - media not supported” and terminate the call.

I think the problem is the way I am calling FaxReceive() - I need to spend some time with the source and see if I can send an argument that says don’t even try T.38 on inbound calls from my Paetec SIP trunk, because they will NEVER be T.38, even though it is a SIP trunk - and I bet that will not be a weird configuration until all the SIP trunk providers get there act together.

So, more testing this weekend when I can muck with our system without disrupting my company - I will post then!

Greg

I’m curious to see how your faxing is going. I’m still having T.38 problems occasionally; mainly with pass-through. This is terribly problematic when the same server is doing T.38 faxing to another T.38 enabled client; it passes through but sometimes things get fairly fouled up. Then you have to switch back to G.711. This is why T.38 gatewaying is so important. In theory, the server should then act as a gateway and relay the info between the two locally connected clients.

How is your G.711 testing doing on the SPA2102? Any specific settings you have found?

Thanks

Brock

I didn’t change any of the default settings on the SPA2102 other than the SIP settings we use and the RTP range (we like a Non-Standard range) - Those boxes are amazing and I would HEARTILY recommend them to anyone!

I am wondering if your T.38 Gateway (Your SIP Provider) is the problem - We are using Paetec, and since I have discovered the SPA2102, I have yet to have a FAX fail - And I have even cranked the settings that I used to turn off like V.34 and ECM - and it’s still working - and this is all In-Band G.711 FAXing.

On another note, the current 1.6.2.0.rc4 seems very unstable with SIP trunks - as I posted before, I had to switch back to 1.6.1.9 - and since they released it today, I am going to upgrade to 1.6.1.10 tonight - the bug-fix list is HUGE.

Finally, I am going to post a cleaner How-To this weekend - this is now our standard build, and I want make it easy for anyone else to set it up like I did.

Greg

Started reading up on fax with asterisk last night and trying to get my head around how to get our fax machine up and running when we switch from PSTN to SIP trunk in a couple of weeks. Reading through this thread you’re (Greg) mentioning the SPA 2102 from Linksys… I fail to find much info on it though - could it be made to register as an extension on our Asterisk 1.6.0.10 server and be used to receive fax from our fax machine and send it out on a T38 channel (our Sip Trunk provider has full T.38 passthrough according to them).

Got the ReceiveFAX working last night with minimal hassle but the Sending part eludes me :wink:

Greg,

Have you had any experience with PAP2T’s? If so, how does it compare to the SPA 2102? I’ve got over 20 analog faxes hanging off a mix of grandstream equipment, and I’m not having any luck with larger faxes, etc.

my setup is: fax----->Grandstream(486,386,286)-----Asterisk(digium210B)—XO-PRI

Grandstreams have all been configured for g711 with fax passthrough. (not using the t38 option. and dtmf is configured for inband on the ata and the extension in asterisk.)

I need to go readup on t38 some more, I was under the impression the fax machine had to be t38 fax aware for it to be of any use.

I’m in the middle of trying to cobble together 1.6.1.10 and NVfax as per your original post.

Thanks,

Kirk