Help me with callback

Good day.

I have using callback files scheme for bridging 2 numbers thru asterisk with next settings:
callfile:

Channel: Local/1617@dialout-murdozcb
Set: CALLERIDNUM=1617
Context: callback-murdozcb
Extension: 99312
WaitTime: 60
Priority: 1

extesions.conf
[dialout-murdozcb]
exten => h,1,Hangup()

exten => _XXXXXX.,1,Dial(SIP/${EXTEN}@voicetrading)
exten => _XXXXXX.,2,Hangup

[callback-murdozcb]
exten => h,1,Hangup()

exten => _XXXXXX.,1,Answer
exten => _XXXXXX.,2,Playback(beep)
exten => _XXXXXX.,3,Dial(IAX2/1stggateway/${EXTEN})
exten => _XXXXXX.,4,Hangup

[color=blue]Calling process is ok for both sides,
but when 1st call-leg established, script is executing hangup[/color]
but call is not hanging phisically, after this asterisk normally calling to 2nd side and establish bridging.

But i not need this hangup, it is cancelling billing process for 1st leg.
When i am erase 1,Answer directive from 2nd extension, hangup is not doing, but no sound on both side in established call.

What is solution for this problem ?

[color=red]Screen from debug:[/color]
– Attempting call on Local/1617@dialout-murdozcb for 1617@callback-murdozcb:1 (Retry 1)
– Executing [1617@dialout-murdozcb:1] Dial(“Local/1617@dialou
t-murdozcb-407b,2”, “SIP/1617@voicetpovider”) in new stack
– Called 1617@voicetprovider
– Call on SIP/voiceprovider-08cddb20 left from hold
– SIP/voicetprovider-08cddb20 is making progress passing it to Local/1617@dialout-murdozcb-407b,2
– Call on SIP/voiceprovider-08cddb20 left from hold
– SIP/voiceprovider-08cddb20 answered Local/1617@dialout-murdozcb-407
b,2
– Executing [99312@callback-murdozcb:1] Answer(“Local/1617@dia
lout-murdozcb-407b,1”, “”) in new stack
– Executing [99312@callback-murdozcb:2] Playback(“Local/1617@d
ialout-murdozcb-407b,1”, “beep”) in new stack
– <Local/1617@dialout-murdozcb-407b,1> Playing ‘beep’ (language ‘en’
)
== Spawn extension (dialout-murdozcb, 1617, 1) exited non-zero on ‘Local/1617@dialout-murdozcb-407b,2’
– Executing [h@dialout-murdozcb:1] Hangup("Local/1617@dialout-murdoz

[quote=“nickpiter”][dialout-murdozcb]
exten => h,1,Hangup()

exten => _XXXXXX.,1,Dial(SIP/${EXTEN}@voicetrading)
exten => _XXXXXX.,2,Hangup

But i not need this hangup, it is cancelling billing process for 1st leg.
[/quote]

Then why do you need priority 2 to hang up?

You can use the h (hangup) extension in the context where the call is made. In this extension you can do anything that is needed to make a proper (administrative) end to the call. My advice is to test it properly before take it into production. Not all standard channel variables are available.

You don’t need the local channel. You can do

exten => s,1 read(variable_to_process|soundfile_to_ |1) ; see voip-info.org/wiki/index.php … k+cmd+Read

exten => s,2,Dial($VOOPTRUNK1/variable_to_process,20,r)

etc. etc.

To my experience, local channels are very unpredictable in their behaviour.

In the h, extension you can use the ${ANSWEREDTIME} variable to get the number of seconds of the call (from pickup until hangup).This value should be the same for both legs.

This is a copy and paste from a working implementation:
exten => h,n,Set(600_SEC_Price=300)
exten => h,n,Set(CALL_COSTS= $[ (${ANSWEREDTIME} * ${600_SEC_PRIJS} / 600) + 4])

300 is the price for 10 minutes calling (600 seconds), the 4 is the starting fee