[asterisk-users] Looking for better fax handling

John Kiniston johnkiniston at gmail.com
Mon May 21 19:04:11 CDT 2018


Lock files.

Create one when you start sending the fax, on your retry process check for
a lock file and if one exists don't retry.

On Mon, May 21, 2018 at 10:49 AM, D'Arcy Cain <darcy at vybenetworks.com>
wrote:

> I am having troubles with sending faxes.  I hope someone can help me
> work out a better method.
>
> Basically we have a special address that our users can send to.  It
> winds up on our Asterisk server which runs a Python script that parses
> the message for attachments and the phone number from the recipient
> address.  The attachments are converted to TIFF and stored in a folder
> with various information encoded into the file name such as phone number
> and retry information.  That all works fine.
>
> A separate process picks up the files and sends them using an AMI script
> like this:
>
> Action: Originate
> Channel: SIP/provider/%(destination)s
> Context: LocalSets
> CallerID: Vybe Consulting Inc Fax Service <6475551212>
> Exten: sendfax
> Priority: 1
> Timeout: 30000
> Variable: faxfile=%(faxfile)s
> Variable: uid=%(uid)s
> Variable: destination=%(destination)s
> Variable: sender_name=Vybe Consulting Inc Fax Service
> Variable: sender_num=6475551212
>
> It then renames the file encoding the next retry time and incrementing
> the number of retries.
>
> The same script checks for files in a success folder and sends the users
> a confirmation message that the fax was sent.  The files are moved into
> the success folder by Asterisk using this dialplan:
>
> sendfax,1,Verbose(0,FAX ${faxfile} to ${destination})
>   same => n,Set(FAXOPT(headerinfo)=${sender_name})
>   same => n,Set(FAXOPT(localstationid)=${sender_num})
>   same => n,SendFax(${faxfile},d)
>   same => n,Set(STATUS=Status: ${FAXOPT(status)})
>   same => n,Set(STATUS=${STATUS}\nRemote ID: ${FAXOPT(remotestationid)})
>   same => n,Set(STATUS=${STATUS}\nMaxrate: ${FAXOPT(maxrate)})
>   same => n,Set(STATUS=${STATUS}\nMinrate: ${FAXOPT(minrate)})
>   same => n,Set(STATUS=${STATUS}\nECM: ${FAXOPT(ecm)})
>   same => n,Set(STATUS=${STATUS}\nnumber of pages: ${FAXOPT(pages)})
>   same => n,Set(STATUS=${STATUS}\nRate: ${FAXOPT(rate)})
>   same => n,Set(STATUS=${STATUS}\nResolution: ${FAXOPT(resolution)})
>   same => n,GotoIf($["${FAXOPT(status)}" = "SUCCESS"]?faxok)
>   same => n,Set(STATUS=${STATUS}\nError: ${FAXOPT(error)})
>   same => n(faxok),Verbose(0,FAX ${destination} Status (S): ${STATUS})
>   same => n,Set(FAXNAME=${CUT(faxfile,/,6)})
>   same => n,Set(FILE(/fax_status/${FAXNAME})=${STATUS})
>   same => n,GotoIf($["${FAXOPT(status)}" != "SUCCESS"]?faxfail)
>   same => n,System(/bin/mv '${faxfile}' '/fax_success/${FAXNAME}')
>
>   same => n,Set(CDR(userfield)=${destination})
>   same => n,Verbose(0,FAX to ${destination} charged to ${uid})
>   same => n(faxfail),Verbose(0,FAX ${destination} Status (F): ${STATUS})
>   same => n,Hangup()
>
> My problem is that if the faxes get too big it starts sending it again
> before the previous one has finished.  I can't raise the retry limit too
> far because sometimes the receiver is busy and we have to retry in a
> reasonable time.
>
> Is there a way to get a token from the AMI script that I can use to
> determine later if Asterisk is still busy with the fax before I try
> sending it again?
>
> Or, am I approaching this all wrong?  Is there a better method of doing
> this?
>
> I am running Asterisk 13.19.0 on NetBSD/amd64 7.1.0.
>
> --
> D'Arcy J.M. Cain
> Vybe Networks Inc.
> http://www.VybeNetworks.com/
> IM:darcy at Vex.Net VoIP: sip:darcy at VybeNetworks.com
>
>
>
>
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> Check out the new Asterisk community forum at: https://community.asterisk.
> org/
>
> New to Asterisk? Start here:
>       https://wiki.asterisk.org/wiki/display/AST/Getting+Started
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users
>



-- 
A human being should be able to change a diaper, plan an invasion, butcher
a hog, conn a ship, design a building, write a sonnet, balance accounts,
build a wall, set a bone, comfort the dying, take orders, give orders,
cooperate, act alone, solve equations, analyze a new problem, pitch manure,
program a computer, cook a tasty meal, fight efficiently, die gallantly.
Specialization is for insects.
---Heinlein
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20180521/ef553f6d/attachment.html>


More information about the asterisk-users mailing list