[Freeswitch-users] Faxing with FreeSWITCH

bruce at sqls.net bruce at sqls.net
Tue Mar 25 03:56:33 MSK 2014


I actually did that after reviewing some captures in wireshark and I 
realized the silence was just taking up time at the start. This is what 
I have now.

session:answer()
session:execute("spandsp_start_fax_detect", "rxfax '/tmp/FAX-" .. uuid 
.. ".tif'")
session:execute("playback", "silence_stream://15000")
session:hangup()

With that, I don't even need the sleep. So it's commented out and the 
system plays silence for the 15 seconds while it listens for a fax tone. 
If it never gets a tone then all the session variables that rxfax sets 
are empty so later on in the script if those are empty I just set the 
error as "No fax detected, possible voice call" for my logging and 
e-mail notifications stuff. I thought about having the fax_detect just 
set a variable and run a while loop to detect the variable (with a 
timeout) but that seems more wasteful on resources and likely to break 
somehow creating an endlessly running loop.

Thanks for the comments from everyone else too. The IVR ideas make sense 
if I took voice calls but this is a 100% fax only system. I suppose I 
could play a notice announcement like "This is a fax system. Please 
start you fax now or hangup"... Maybe later :) The recommendations to 
have the fax_detect switch to other parts of the dialplan won't work for 
me since I'm doing this all 100% inside a LUA script.. Or at least I 
don't think they would work. I don't know how to register dialplan 
extensions inside a LUA script.

I think this brings me to my #2 question. When faxes don't work. How do 
I go about finding the problem? Right now, like I mentioned initially, 
the majority of my failed faxes just give the error "The call dropped 
prematurely". I'm currently pretty clueless on knowing where to go with 
that...

Right now my script pulls out the entire freeswitch log for the call and 
puts it into a file named based on the call uuid. Then I have 
pcapsipdump running which gives me a log of the sip/rdp/t38 packets. I 
also log all the channel and rxfax variables into a sqlite database for 
each call. So I've got tons of data to look at :) I've been toying 
around with wireshark but I have no idea what the call is suppose to 
look like :). The feature in wireshark that lets me play the audio seems 
the most helpful for me because I can at least listen to see if any fax 
tones or weird static is on the line.

Is there a good guide I could reference to understand at least the 
initial negation of a ulaw/t38 fax call? That way I'll have a starting 
clue on where a problem might be.

------ Original Message ------
From: "Tim St. Pierre" <fs-list at communicatefreely.net>
To: freeswitch-users at lists.freeswitch.org
Sent: 3/24/2014 7:31:50 PM
Subject: Re: [Freeswitch-users] Faxing with FreeSWITCH

>Switch the fax detect and silence_stream so that fax detect happens
>first. You want Freeswitch to be listening during the silence stream.
>What's probably happening right now is that the fax isn't detected 
>until
>you are in the 15s sleep.
>
>
>
>On 14-03-24 05:19 PM, bruce at sqls.net wrote:
>>
>>  Ah, thanks for the info on fax detect.. With that and reading some 
>>more
>>  examples/docs I tried this..
>>
>>  session:answer()
>>  session:execute("playback", "silence_stream://2000")
>>  session:execute("spandsp_start_fax_detect", "rxfax '/tmp/FAX-" .. 
>>uuid
>>  .. ".tif'")
>>  session:sleep(15000);
>>  session:hangup()
>>
>>
>>  Which seems to work. Once it detects a fax it fire's off the rxfax 
>>app.
>>    I'm not sure if maybe there's a better method to do this or not. 
>>This
>>  doesn't really leave me a variable saying that no fax was detected
>>  outside the lack of result variables from rxfax but maybe that's good
>>  enough. Any ideas on a better solution, anyone? :)
>>
>>  On a side note. Does anyone know -why- the playback silence_stream is
>>  needed? Or is it not needed at all? I see that in almost every 
>>example
>>  on using FreeSWITCH faxing but I'm not sure what it's purpose is.
>>  Thanks.
>>
>>
>>  ------ Original Message ------
>>  From: "Tim St. Pierre" <fs-list at communicatefreely.net>
>>  To: freeswitch-users at lists.freeswitch.org
>>  Sent: 3/24/2014 3:15:08 PM
>>  Subject: Re: [Freeswitch-users] Faxing with FreeSWITCH
>>
>>>  The fax detect function starts listening for fax tones while the 
>>>call
>>>  continues. You are right, in that it is a non-blocking function.
>>>
>>>  What you probably need to do, after making sure that media is
>>>  established, is call fax detect, then give the caller something to 
>>>do
>>>  while you wait for a possible fax tone. You could just play silence 
>>>to
>>>  the caller for a few seconds, unless there was something more 
>>>relevant
>>>  to do. I believe that the original intent of fax detect was to be
>>>  invoked just before an IVR was run, so that a voice caller would 
>>>just
>>>  listen to the menu, but a fax would start making tones that could 
>>>then
>>>  be detected, transferring the call to the named extension where it
>>>  would
>>>  be answered as a fax.
>>>
>>>  Hope that helps!
>>>
>>>  On 14-03-24 01:49 PM, bruce at sqls.net wrote:
>>>>
>>>>   Hello! I'm working on setting up a FreeSWITCH/Flowroute fax 
>>>>server.
>>>>  The
>>>>   server is connected without any nat on a 20MB fiber internet
>>>>  connection.
>>>>   I've built some lua scripts that allow me to receive and send 
>>>>faxes
>>>>  and
>>>>   log all the faxes to a sqlite database. I even have a management
>>>>  script
>>>>   that can be called from the fs_cli to add fax2email routes and 
>>>>adjust
>>>>   settings. It's still a pretty rough implementation but overall 
>>>>it's
>>>>   working fairly well but I have two main questions that I hope 
>>>>someone
>>>>   could help me with.
>>>>
>>>>   1) I would like to detect "voice calls" or maybe I want to detect 
>>>>fax
>>>>   calls? There's a dialplan function to listen for and detect a fax
>>>>  caller
>>>>   but I'm having trouble implementing it in my lua script. It seems
>>>>  it's a
>>>>   non-blocking function, maybe? Because it just walks right over 
>>>>that
>>>>  line
>>>>   instead of waiting and listening for any fax tones. I thought it
>>>>  would
>>>>   block the script for x seconds and listen for a fax tone and 
>>>>return a
>>>>   result based on what it found. Can someone help me accomplish
>>>>  something
>>>>   similar to that?
>>>>
>>>>   2) So far, by far... my most common error is "The call dropped
>>>>   prematurely". I'm not sure how to start debugging the error to 
>>>>figure
>>>>   out what's causing it and how (if I can) solve it. I do have 
>>>>pcap's
>>>>  of
>>>>   the calls from pcapsipdump and I also have the freeswitch log of 
>>>>each
>>>>   call (my lua script pulls and saves that for each fax call). I've
>>>>  opened
>>>>   the pcap files up in wireshark but I don't know what I'm looking 
>>>>for
>>>>  and
>>>>   I think that might be over my head at the moment. Can anyone give 
>>>>me
>>>>  any
>>>>   help on what this error is normally caused by or what I could look
>>>>  for
>>>>   and/or test?
>>>>
>>>>   Here are a couple of example logs that ended with "The call 
>>>>dropped
>>>>   prematurely".
>>>>   
>>>>http://bmts.us/faxlogs/FAX-2e913a50-3a4f-4abc-9882-a323a97e5138.log
>>>>   
>>>>http://bmts.us/faxlogs/_FAX-59d02d9d-c4ba-44c2-8edd-a1c9142c7c1c.log_
>>>>   
>>>><http://bmts.us/faxlogs/FAX-59d02d9d-c4ba-44c2-8edd-a1c9142c7c1c.log>
>>>>   __
>>>>   __
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>  
>>>>_________________________________________________________________________
>>>>   Professional FreeSWITCH Consulting Services:
>>>>   consulting at freeswitch.org
>>>>   http://www.freeswitchsolutions.com
>>>>
>>>>   
>>>>   
>>>>
>>>>   Official FreeSWITCH Sites
>>>>   http://www.freeswitch.org
>>>>   http://wiki.freeswitch.org
>>>>   http://www.cluecon.com
>>>>
>>>>   FreeSWITCH-users mailing list
>>>>   FreeSWITCH-users at lists.freeswitch.org
>>>>   http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>
>>>>  
>>>>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>>   http://www.freeswitch.org
>>>>
>>>
>>>  
>>>_________________________________________________________________________
>>>  Professional FreeSWITCH Consulting Services:
>>>  consulting at freeswitch.org
>>>  http://www.freeswitchsolutions.com
>>>
>>>  
>>>  
>>>
>>>  Official FreeSWITCH Sites
>>>  http://www.freeswitch.org
>>>  http://wiki.freeswitch.org
>>>  http://www.cluecon.com
>>>
>>>  FreeSWITCH-users mailing list
>>>  FreeSWITCH-users at lists.freeswitch.org
>>>  http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>  
>>>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>  http://www.freeswitch.org
>>
>>
>>  
>>_________________________________________________________________________
>>  Professional FreeSWITCH Consulting Services:
>>  consulting at freeswitch.org
>>  http://www.freeswitchsolutions.com
>>
>>  
>>  
>>
>>  Official FreeSWITCH Sites
>>  http://www.freeswitch.org
>>  http://wiki.freeswitch.org
>>  http://www.cluecon.com
>>
>>  FreeSWITCH-users mailing list
>>  FreeSWITCH-users at lists.freeswitch.org
>>  http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>  
>>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>  http://www.freeswitch.org
>>
>
>_________________________________________________________________________
>Professional FreeSWITCH Consulting Services:
>consulting at freeswitch.org
>http://www.freeswitchsolutions.com
>
>
>
>
>Official FreeSWITCH Sites
>http://www.freeswitch.org
>http://wiki.freeswitch.org
>http://www.cluecon.com
>
>FreeSWITCH-users mailing list
>FreeSWITCH-users at lists.freeswitch.org
>http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>http://www.freeswitch.org




Join us at ClueCon 2013 Aug 6-8, 2013
More information about the FreeSWITCH-users mailing list