Callfile click2call first call leg hangup detection


I have following scenario (kind of click2call):

I create callfile that initiates call over SIP trunk. Something like Channel: SIP/trunk/number.
Answered call goes to context that has AGI script to initiate the call to second call party.

This works OK, calls are made but there is problem with proper hang up detection.

When first call leg hangups call, only his call leg is disconnected, second call leg remains active until timeout.

The question is how to hang up second call leg when the first hangs up connection?

I will greatly appreciate your help

Most likely problem: You are calling a PSTN number in a country like the UK, which doesn’t, normally at least, allow called party clearing on the PSTN. This is done to allow the callee to put down the phone and pick up another one, without losing the call.

Second possible problem: The PSTN interface hasn’t been properly configured for disconnect supervision, or doesn’t allow it (may not even be an offered service on analogue lines).

In the second case, I believe Asterisk has some capability for detecting busy tones on the line and inferring a hangup from them, but I’ve not used such a configuration.

In the UK, you can generally distinguish between these because mobile numbers do implement called party clearing.

Both call legs go through external SIP provider, no PSTN hardware used.

Each call leg can hang up with no problem.

Problem is how to disconnect second call leg when first hangs up or vice versa. I think that asterisk has some problem with associating those two calls and pass hangup event from one channel to another.

Anybody had similar problem?


We have platforms doing similar, making 1000’s of calls per day and don’t see what you are seeing.
You need to do a sip trace of the call and see what messaging is being lost.


Post your dialplan here and a sample call file.