Cannot playback in h extension

Hello!

After one party hangs up, h is executed. But Playback command does not work there!

I use goto command in h extension. This is what I get:

[Oct 12 18:52:11] VERBOSE[31349] pbx.c: – Goto (quiz,s,1)
[Oct 12 18:52:11] VERBOSE[31349] app_macro.c: == Channel ‘SIP/baza5555-000014e3’ jumping out of macro ‘hangupcall’
[Oct 12 18:52:11] VERBOSE[31349] pbx.c: – Executing [s@quiz:1] Verbose(“SIP/baza5555-000014e3”, “2,Starting quiz”) in new stack
[Oct 12 18:52:11] VERBOSE[31349] app_verbose.c: == Starting quiz
[Oct 12 18:52:11] VERBOSE[31349] pbx.c: – Executing [s@quiz:2] Playback(“SIP/baza5555-000014e3”, “custom/q_hi”) in new stack
[Oct 12 18:52:11] WARNING[31349] file.c: Failed to write frame
[Oct 12 18:52:11] VERBOSE[31349] file.c: – <SIP/baza5555-000014e3> Playing ‘custom/q_hi.alaw’ (language ‘ru’)
[Oct 12 18:52:11] WARNING[31349] app_playback.c: ast_streamfile failed on SIP/baza5555-000014e3 for custom/q_hi
[Oct 12 18:52:11] VERBOSE[31349] pbx.c: – Executing [s@quiz:3] Read(“SIP/baza5555-000014e3”, “a1,1,n,2,10”) in new stack
[Oct 12 18:52:11] VERBOSE[31349] app_read.c: – Accepting a maximum of 1 digits.
[Oct 12 18:52:11] VERBOSE[31349] app_read.c: – User disconnected
[Oct 12 18:52:11] VERBOSE[31349] pbx.c: – Executing [s@quiz:4] Verbose(“SIP/baza5555-000014e3”, "2,Answered ") in new stack
[Oct 12 18:52:11] VERBOSE[31349] app_verbose.c: == Answered
[Oct 12 18:52:11] VERBOSE[31349] pbx.c: – Executing [s@quiz:5] AGI(“SIP/baza5555-000014e3”, “quiz.php,1,”) in new stack
[Oct 12 18:52:11] VERBOSE[31349] res_agi.c: – Launched AGI Script /var/lib/asterisk/agi-bin/quiz.php
[Oct 12 18:52:11] VERBOSE[31349] res_agi.c: – <SIP/baza5555-000014e3>AGI Script quiz.php completed, returning 0
[Oct 12 18:52:11] VERBOSE[31349] pbx.c: – Executing [s@quiz:6] Hangup(“SIP/baza5555-000014e3”, “”) in new stack
[Oct 12 18:52:11] VERBOSE[31349] features.c: == Spawn extension (quiz, s, 6) exited non-zero on ‘SIP/baza5555-000014e3’

Is it possible to playback something to only remaining party if one party hangsup? I would like to playback a question to give a rating from 1 to 5, but it can be “bye” - anything…

h is run after the media closes on the incoming channel, so cannot do anything that involves media.

Closing the media on the incoming channel closes it on the outgoing channel.

You can continue processing on the incoming channel, if only the outgoing one clears, using the g option in Dial, but you can’t do anything media related once the incoming one clears.

Right, here is what this page (voip-info.org/wiki/view/Asterisk+h+extension) says:

When the ‘h’ extension is running, the call legs have already been torn down. There is no way to delay this happening, and you can’t do anything in the ‘h’ extension that needs to read audio from the channel (since no audio will appear, the first time it tries to read audio it will abort). Thus Playback() or Background(), for example, does not work. Essentially, the only things that make sense to use in the ‘h’ extension are those that don’t have anything to do with the external channel that was involved before the hangup. No audio, no DTMF, etc.

But, amazingly, I had Asterisk setup where I transferred a call from h extension to a context using goto, and both Read() and Playback() worked there, sounds were played back to calling customer after call center agent hanged up the call. How could that be?

When the call is going to ‘h’, its usually done as far as the media goes.

Were you sending the active call to ‘h’ instead of the automatic action of “call has hung up so its auto sent to ‘h’”?

It worked like this - customer calls to call center, agent picks up, talks with customer, and then agent hangs up. Customer is then immediately taken to quiz where Playback() plays questions and Read() reads the reply.

Here is what we used:

[code][groupon_queue0_ctxt]
exten => s,1,Set(MONITOR_FILENAME=/monitor/spool/${CALLERID(NUM)}_${UNIQUEID})
exten => s,n,Set(MONITOR_EXEC=/usr/local/etc/asterisk/scripts/asterisk-monitor.sh)
exten => s,n,Set(CALLERID(name)=GroupOn)
exten => s,n,GotoIfTime(8:00-22:00|mon-sun||?1,1)
exten => s,n,Goto(99,1)
exten => 1,1,Queue(queue0_day,HtTw,peer_log_number.php)
exten => h,1,Set(CDR(qeholdtime,r)=${QEHOLDTIME})
exten => h,2,Set(CALLERID(name)=${MEMBERINTERFACE})
exten => h,3,Goto(quiz,s,1)
exten => 99,1,Playback(cc_offtime)
exten => 99,2,Hangup()
exten => #,1,Goto(groupon_ivr_ctxt,s,root)

[quiz]
exten => s,1,Verbose(2,Starting quiz)
exten => s,2,Playback(custom/q_hi)
exten => s,3,Read(a1,1,n,2,10)
exten => s,4,Verbose(2,Answered ${answ})
exten => s,5,AGI(quiz.php,1,${a1})
exten => s,n,Hangup()[/code]

Hi Varnav, I’m trying to make the same setup but for me isn’t working.
I got always:

Which version of Asterisk do you use?

Thanks

He’s probably using a dahdi analogue channel. These are 1:1 with the Asterisk channels, so, whilst officially undefined, there will be an obvious channel associated with the Asterisk channel, even after the end of the call.

No, it’s pure SIP channels.

I have asterisk 11.4 currently.

Any attempt to send media in an h extension is operating Asterisk out of specification. The correct way of handling this is with the g option on Dial. (I haven’t researched this on Queue, but you can add a Local channel, to turn the problem into a Dial one.)