[Resolved] Hangup() doesn't work?

From extensions.conf, does NOT work (system just lets the line ring continually, so for some reason it’s not even doing the FIRST item!):

[Sample]
exten => s,1,Answer()
exten => s,2,Hangup()

Oddly enough, the following works perfectly fine:

[Sample]
exten => s,1,Answer()
exten => s,2,Echo()

What am I missing here?

works fine here … let’s see a log file fragment for a failed call ?

OK, this gets stranger and stranger… I tried the following sample from the book, and it works fine.

[Sample]
exten => s,1,Answer()
exten => s,n,Playback(hello-world)
exten => s,n,Hangup()

So, I then compared that to my previous attempts and noted the use of “n” instead of numbered instructions. Tried that (such as follows), and I’m back to the system not even picking up the lines! Is it an “illegal op” to answer and immediately hangup?

[Sample]
exten => s,1,Answer()
exten => s,n,Hangup()

I’ll go hunt down log files now too :smile:

OK, here’s the logs of starting asterisk, followed immediately by the failed answer/hangup sequence.

Mar 7 12:06:18 NOTICE[5171] cdr.c: CDR simple logging enabled.
Mar 7 12:06:18 WARNING[5171] db.c: Unable to open Asterisk database
Mar 7 12:06:18 WARNING[5175] res_musiconhold.c: Found no files in ‘/var/lib/asterisk/mohmp3’
Mar 7 12:06:18 WARNING[5175] res_musiconhold.c: Unable to spawn mp3player
Mar 7 12:06:18 WARNING[5171] db.c: Unable to open Asterisk database
Mar 7 12:06:18 WARNING[5171] db.c: Unable to open Asterisk database
Mar 7 12:06:18 WARNING[5171] db.c: Unable to open Asterisk database
Mar 7 12:06:18 ERROR[5171] chan_alsa.c: snd_pcm_open failed: No such device
Mar 7 12:06:18 ERROR[5171] chan_alsa.c: snd_pcm_open failed: No such device
Mar 7 12:06:18 ERROR[5171] chan_alsa.c: Problem opening alsa I/O devices
Mar 7 12:06:18 WARNING[5171] db.c: Unable to open Asterisk database
Mar 7 12:06:18 WARNING[5171] db.c: Database unavailable
Mar 7 12:06:18 WARNING[5171] db.c: Unable to open Asterisk database
Mar 7 12:06:18 ERROR[5171] chan_capi.c: Unable to load config capi.conf, CAPI disabled
Mar 7 12:06:18 WARNING[5171] db.c: Unable to open Asterisk database
Mar 7 12:06:18 WARNING[5171] db.c: Database unavailable
Mar 7 12:06:46 NOTICE[5193] chan_zap.c: Got event 18 (Ring Begin)…
Mar 7 12:06:48 NOTICE[5193] chan_zap.c: Got event 2 (Ring/Answered)…
Mar 7 12:06:58 NOTICE[5197] chan_zap.c: Got event 18 (Ring Begin)…
Mar 7 12:07:00 NOTICE[5197] chan_zap.c: Got event 2 (Ring/Answered)…
Mar 7 12:07:14 WARNING[5201] chan_zap.c: CallerID returned with error on channel ‘Zap/4-1’

Note that the Got event items will repeat until I hang up the calling phone, then the CallerID thing appears.

Asterisk seems to be occupied by more than what your sample dialplan asks for. Maybe you need to examine the entire configuration. (e.g., why it insists on opening DB for Answer() and Hangup()? And why it tries to open chan_alsa?)

My extensions.conf file is much larger than that. [sample] is just the snipped out part that doesn’t seem to work properly. The thing that makes me wonder what’s going on is that it DOES work if I playback a sound file before hanging up… I’m not so much worried about the database and alsa stuff at this time…

The CLI output is probably not in the range of the call. I got the following

-- Starting simple switch on 'Zap/4-1' -- Executing Answer("Zap/4-1", "") in new stack -- Executing Hangup("Zap/4-1", "") in new stack == Spawn extension (pstn, s, 2) exited non-zero on 'Zap/4-1' -- Hungup 'Zap/4-1'

Like you said, the line continues to ring as if nothing happened. I suspect it’s because the off-hook period is too short for CO to detect. You can insert a Wait(1) to actually pick up and hang up the call.

Thank you! Works fine now.

Just curious: what’s this context for? Thought this was a mere test to screw up Asterisk :wink:

I have a couple lines set aside for “outgoing only” (as part of a forwarding system). I want them to be available as much as possible and not tied up “ringing” (as can happen with wrong numbers and those “drive-by telemarketers” that like to tie up big blocks of numbers. . So, the best solution I have so far, to keep the outgoing lines as available as possible, is to pickup an incoming call on those lines and immediately hangup!