Call file: Call failed to go through, reason (0) Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)

[deleted the other topic by mistake, not sure what happened there, sorry for the noise]

Hi,

I am running Asterisk 20.6 with PJSIP on a Docker container and have managed to set it up such that incoming calls are correctly answered using an SBC, where port 5740 has been reserved for me and SBC_HOST_1 is the domain of the SBC which is passed as an environment variable. Now I would like to use call files for outgoing calls. Here is what the relevant part of my pjsip.conf looks like (I am using TLS for transport, this part works for incoming calls and OPTIONS):

[global]
type=global
user_agent=Asterisk

[my-sbc1]
type=endpoint
context=sip-incoming-sbc1
disallow=all
allow=ulaw
allow=alaw
allow=g722
aors=my-sbc1
media_encryption=sdes
media_encryption_optimistic=yes
transport=transport-tls
direct_media=no
dtmf_mode=rfc4733
rtp_symmetric=yes

[my-sbc1]
type=aor
contact=sip:${SBC_HOST_1}:5740
qualify_frequency=30

[my-sbc1]
type=identify
endpoint=my-sbc1
match=${SBC_HOST_1}
srv_lookups=no

My call file looks as follows, where I am trying to call the number +1234567890 and want to use the number +987654321 for the call:

Channel: PJSIP/my-sbc1/sip:+1234567890
Callerid: +987654321
WaitTime: 60
Context: sip-outgoing
Extension: 54321
Priority: 1

And here is my extensions.conf for sip-outgoing, where I am trying to execute a script named my_file.agi using AGI:

[sip-outgoing]
exten => _X.,1,AGI(my_file.agi)

When I do this, I get the following in my logs:

VERBOSE[825][C-00000002]: pbx.c:4439 __ast_pbx_run: Spawn extension (sip-incoming-sbc1, +987654321, 2) exited non-zero on 'PJSIP/my-sbc1-00000001'
VERBOSE[831]: pbx_spool.c:442 attempt_thread: Attempting call on PJSIP/my-sbc1/sip:+1234567890 for 54321@sip-outgoing:1 (Retry 1)
VERBOSE[831]: dial.c:474 begin_dial_channel: Called my-sbc1/sip:+1234567890
NOTICE[831]: pbx_spool.c:450 attempt_thread: Call failed to go through, reason (0) Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)

What could be the cause of this? Is this something that can be fixed within Asterisk itself, or is something that comes from the provider? Since I am new to Asterisk and VoIP in general, I may have some conceptual gaps - any pointers in the right direction are appreciated.

This is not a valid Dial string[1] for PJSIP. It requires a full URI and one is not specified. To dial the number, and not a SIP URI you would use:

PJSIP/+1234567890@my-sbc1

[1] Dialing PJSIP Channels - Asterisk Documentation

Thank you for your answer! Unfortunately, this has not solved it yet (the logs stay the same).

One conceptual question: I forgot to mention that I want to call any number, not just one that is associated with the endpoint I am using. Is my general approach even correct?

Yes.

You need to do troubleshooting:

  1. Does Asterisk consider the remote side reachable? (pjsip show contacts or pjsip show endpoints)
  2. If it is reachable is a call attempt made over SIP (pjsip set logger on)
  1. Yes, the my-sbc1 side is reachable:
ip-10-6-20-142*CLI> pjsip show contacts

  Contact:  <Aor/ContactUri..............................> <Hash....> <Status> <RTT(ms)..>
==========================================================================================

  Contact:  my-sbc1/sip:{SBC_HOST_1}:57 fa33af0467 Avail        19.007
  1. I cannot see any call attempts when “pjsip set logger on” is done, but I do see the same logs as the ones in the original post, and there, it says that a call is attempted.

Did you do “pjsip set logger on” and then do an attempt? What are you now precisely doing for a call file?

Yes, I did attempt a call while “pjsip set logger on” was running.

More background: I have an AGI/Python script that is executed once a number on my endpoint is called; the idea is that once this original call concludes, the original caller should be called back. In this script, I manually build the call file as follows:

registerName = "myfile.call"
file_content = "Channel: PJSIP/+1234567890@my-sbc1\nCallerid: +987654321\nWaitTime: 60\nContext: sip-outgoing\nExtension: 54321\nPriority: 1"
os.makedirs("/var/spool/asterisk/callback_register/", exist_ok=True)
f = open("/var/spool/asterisk/callback_register/" + registerName, 'w')
f.write(file_content)
f.close()
calltime = datetime.datetime.now() + datetime.timedelta(seconds = 10)
calltime = datetime.datetime.strftime(calltime, "%Y%m%d%H%M.%S")
os.system("touch -t " + calltime + " /var/spool/asterisk/callback_register/" + registerName)
os.system("mv /var/spool/asterisk/callback_register/* /var/spool/asterisk/outgoing/")

In particular, I have read that one should create the file somewhere else and then move it to the /outgoing directory.

EDIT: changed file_content such that it is completely hard-coded.

What is actually in the call file? To me it looks as though there are going to be bogus quotation marks.

Apologies, this was an artifact from the fact that I am passing the number dynamically, I edited it now. I have looked at the content of the .call file, it looks precisely as expected, no additional quotation marks or anything like that (no newline character after the last line though):

Channel: PJSIP/+1234567890@my-sbc1
Callerid: +987654321
WaitTime: 60
Context: sip-outgoing
Extension: 54321
Priority: 1

EDIT: If this helps, here is the result of ls -a:

-rw-r--r-- 1 asterisk asterisk 127 Apr  3  2025 myfile.call

Update: I finally got to talk to the guy from the SBC, he apparently forgot to add our numbers which is a necessary criterion for it to work… it now works. Thank you very much for your replies!