Fax call not retried

Despite being mentioned in the call file, the fax calls are not retried. Maybe some of them are retried because I sometimes see callfiles in the spool directory where Asterisk appended some timestamp, but until now I did not see a retry (admittetly, I did not overlook all of the calls). I should see the retries by a syslog entry of a program that is executed at the end of a call, but there are none.

This is a sample of a callfile:

Channel:Local/faxout@fax_caller
MaxRetries:9
WaitTime:45
Context:fax_caller
Extension:faxsend
Priority:1
Set:ChannelPrefix=PJSIP/sip_myprovider/sip
Set:ChannelPostfix=myproviderdomain:5084
Set:TIFF_FILE=loremipsum.tif
Set:UniqId=someuniqueid
Set:TAGLINE=blabla
Set:OUTBOXID=99999999999
Set:SenderPhoneNr=+43999999999
Set:ReceiverPhoneNr=+438888888888

As of my understanding, for every retry the entire dialplan is rerun with all variables reset. Is this assumption true? Otherwise my dialplan may be completely wrong.

Edit: I found a call that was correctly retried. Its single calls were aborted because the remote end did not respond:

Call failed to go through, reason (3) Remote end Ringing

Edit 2: I found another example where the call was only tried twice instead of 10 times. Could it be that the retrial stops after some reason?

Before I edit the original post a hundreth time I add an own reply…

Calls I observed until now suggest that the retrial stops as soon as the call is answered, even if the fax transmission fails.

So the question should be: How can I make Asterisk continue the retrials if the call is answered but fax transmission fails?

This is an excerpt of my dialplan, showing the effective dialling and the beginning of the error handling:

same => n,SendFAX(/var/spool/asterisk/fax/${TIFF_FILE},dfsz)
same => n,NoOp(** Fax status: ${FAXSTATUS})
same => n,GotoIf($[ "${FAXSTATUS}" = "SUCCESS" ]?lSuccess:lFailed)

You need add a retry on your dialplan for outbound fax calls and check some variable with fax status before end your attempts.

What do you mean by “add a retry on your dialplan”? Is there a certain application I have to invoke in order to do that? I rather thought about something like telling Asterisk (by use of a variable or a return value or an exception or something else) that the call should be treated the same as if the remote end did not respond in the first place.

That’s my entire dialplan:

[fax_caller]
; Start
exten => faxout,1,NoOp(** Fax caller **)
same => n,Dial(${ChannelPrefix}:${ReceiverPhoneNr}@${ChannelPostfix},,b(fax_outgoing_init^faxout^1(${SenderPhoneNr},${ChannelPostfix})))

; Sending fax
exten => faxsend,1,NoOp(** Sending fax **)
same => n,Set(FAXOPT(headerinfo)=${FaxHeader})
same => n,Set(FAXOPT(localstationid)=${SenderName})
same => n,Set(FAXOPT(ecm)=yes)
same => n,SendFAX(/var/spool/asterisk/fax/${TIFF_FILE},dfsz)
same => n,NoOp(** Fax status: ${FAXSTATUS})
same => n,GotoIf($[ "${FAXSTATUS}" = "SUCCESS" ]?lSuccess:lFailed)
same => n(lSuccess),NoOp(Success)
same => n,Set(status=OK)
same => n,Set(pages=${FAXPAGES})
same => n,Goto(lReady)
same => n(lFailed),NoOp(Failed)
same => n,Set(status=failed)
same => n,Set(pages=0)
same => n,Goto(lReady)
same => n(lReady),NoOp(** Fax sent or failed **)
same => n,Gosub(dlrsend,1(${status},${pages}))

; Delivery notification
exten => dlrsend,1,NoOp(** Sending Delivery Notification **)
same => n,Set(status=${ARG1})
same => n,Set(pages=${ARG2})
same => n,System(/var/www/apps/fax/dlr.php -i '${UniqId}' -u '${DLR_URL}' -s '${status}' -n '${pages}' -t '${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)}')
same => n,Return()

; Hangup
exten => h,1,NoOp(** Hung up **)
same => n,Gosub(dlrsend,1(failed,0))

; Failed
exten => failed,1,NoOp(** Fax failed **)
same => n,Gosub(dlrsend,1(failed,0))

[fax_outgoing_init]
exten => faxout,1,NoOp(** Fax, pre-dial hook **)
same => n,Set(PJSIP_HEADER(add,P-Preferred-Identity)="<sip:${ARG1}@${ARG2}>")
same => n,Return()

I didn’t locate where you invoke faxsend

Put a g option at your dial and check FAXSTATUS at next line. If sucess, hangup else goto Dial again.

A counter to limit your attempts will be required to avoid infinite loop.

For the sake of completeness, faxsend is mentioned in the callfile to be executed after dialling. It is shown in the original post. I just wonder if it is easier to drop this.

I recommend you to add a loop counter to limit your attempts and put a wait before redial since the fax machines normally keep the line open and your next attempt will be not answered immediately.

Ok, so now I have this fragment, but despite the g in the Dial application, it does not continue the extension if the call is hung up during the execution of SendFax. The callfile now jumps to priority 100 in the faxout extension.

[fax_caller2]
exten => faxout,1,NoOp(** Fax caller **)
same => n,Set(retries=3)
same => n(lDial),Dial(${ChannelPrefix}:${ReceiverPhoneNr}@${ChannelPostfix},,gb(fax_outgoing_init^faxout^1(${SenderPhoneNr},${ChannelPostfix})))
same => 100(faxsend),NoOp(** Sending fax **)
same => n,Set(FAXOPT(headerinfo)=${FaxHeader})
same => n,Set(FAXOPT(localstationid)=${SenderName})
same => n,Set(FAXOPT(ecm)=yes)
same => n,SendFAX(/var/spool/asterisk/fax/${TIFF_FILE},dfsz)
same => n,NoOp(** Fax status: ${FAXSTATUS})

My first approach was simply to modify the original dialplan with the g option to Dial, however the FAXSTATUS variable was empty when the control returned to the extension faxout.

Somehow I run into a cat-tail-problem. The Dial application creates a new channel. So, any counter is pointless because I cannot communicate a variable across channels (especially not like a return code) - neither the counter nor the fax status. AFAIK, a concept of “call-global variables” does not exist. So how do I solve that?

The second problem is, that if the call is hung up during execution of the SendFax application, then first the commands after the Dial are executed, end then those after the SendFax command, so it is not even possible to set any variables.

I append my current status, just the beginning of the dialplan, the rest as in the first version:

exten => faxout,1,NoOp(** Fax caller **)
same => n,Dial(${ChannelPrefix}:${ReceiverPhoneNr}@${ChannelPostfix},,gb(fax_outgoing_init^faxout^1(${SenderPhoneNr},${ChannelPostfix})))
same => n,NoOp(*** Status: ${FAXOPT(error)})
same => n,NoOp(*** Pages: ${FAXOPT(pages)})

This shows empty values returned from FAXOPT.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.