[SOLVED] hangup() AGI fires before call actually ends


I have a call (initiated from a call script) from a local handset to an external number.

Once the external number has finished ringing (i.e. people are connected), the call continues (and parties can speak), but the AGI called on hangup() event is fired. I was actually expecting it to be fired when the parties complete their call, but it isn’t! I don’t have these problems for incoming calls (for that, my hangup AGI is called at the right time)

The local handset is PJSIP, the external call is made by IAX2.
Any ideas what I should be looking at?

-- IAX2/voipms-11053 answered Local/6004@from-internal-00000047;1
-- Channel Local/6004@from-internal-00000047;1 joined 'simple_bridge' basic-bridge <894491a2-7b63-4fe1-8d3f-1fc4374b3538>
-- Channel IAX2/voipms-11053 joined 'simple_bridge' basic-bridge <894491a2-7b63-4fe1-8d3f-1fc4374b3538>
   > Move-swap optimizing Local/6004@from-internal-00000047;1 <-- PJSIP/6004-00000073.
-- Channel PJSIP/6004-00000073 left 'simple_bridge' basic-bridge <1b220528-2b40-4f6b-ab59-01b83388c0d1>
-- Channel Local/6004@from-internal-00000047;1 left 'simple_bridge' basic-bridge <894491a2-7b63-4fe1-8d3f-1fc4374b3538>
-- Channel PJSIP/6004-00000073 swapped with Local/6004@from-internal-00000047;1 into 'simple_bridge' basic-bridge <894491a2-7b63-4fe1-8d3f-1fc4374b3538>
-- Channel Local/6004@from-internal-00000047;2 left 'simple_bridge' basic-bridge <1b220528-2b40-4f6b-ab59-01b83388c0d1>

== Spawn extension (from-internal, 5999, 7) exited non-zero on ‘Local/6004@from-internal-00000047;1’
== Spawn extension (from-internal, 6004, 1) exited non-zero on ‘Local/6004@from-internal-00000047;2’
– Local/6004@from-internal-00000047;1 Internal Gosub(hdlr_outgoing,s,1(args)) start

Thanks for any help

I guess this is a classic newbie error.
The answer to the conundrum is to read the article entitled “Local Channel Optimisation”

I just added /n onto my dial command and all was well.