Locked up SIP extension on your Asterisk server? Me too. Here’s how I released it.

I have struggled with this issue for a while on a large deployment (6 servers hosting ~175 extensions). An extension would complete a call, and the SIP channel on the extension side would fail to release when the call terminated, resulting in the extension appearing to be busy to the server. All calls go straight to voicemail. Calls can be initiated just fine, but I could not find a resolution for releasing the channel short of restarting the server, which is obviously not the desired method of resolution. This issues is addressed in the Asterisk ticket here: https://issues.asterisk.org/jira/browse/ASTERISK-19455, but no short-term resolution to the immediate problem of the channel that won’t die.

SO… Today when this issue happened, I stuck with it longer that I had in the past, experimenting with trying to stop the channel. Here’s how I was able to release the extension without a complete reboot of the server.

You can see your active channels from the asterisk CLI command ‘core show channels’:

root@asteriskserver:~ $ asterisk -rvvvvv
Asterisk 1.8.6.0, Copyright (C) 1999 - 2011 Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
== Parsing '/etc/asterisk/asterisk.conf': == Found
== Parsing '/etc/asterisk/extconfig.conf': == Found
Connected to Asterisk 1.8.6.0 currently running on asteriskserver (pid = 3184)
Verbosity was 3 and is now 5
asterisk*CLI>


asterisk*CLI> core show channels
Channel Location State Application(Data)
...
SIP/2215-000002ed 600@from-internal:1 Up AppDial((Outgoing Line))
...
15 active channels
7 active calls
954 calls processed

I have obviously sanitized the output and removed all of the channels except the problem child. You’ll be able to identify if this is the same, or at least a similar, issue by the count at the bottom of the core show channels output. You’ll notice above that the number of active calls and the number of active channels does not match. This is not necessarily indicative of a problem, but you should generally see a 2:1 ratio in active channels and active calls. Legitimate exceptions would be conference calls and call queues, but in our system, it’s generally one channel for each end of the call.

Once you have identified the hung channel, you can get more information about the channel with the command ‘core show channel <channel>’:

asterisk*CLI> core show channel SIP/2215-000002ed
-- General --
Name: SIP/2215-000002ed
Type: SIP
UniqueID: 1357324347.2041
LinkedID: 1357324346.2038
Caller ID: 2215
Caller ID Name: Unhappy Extension User
Connected Line ID: 1573280XXXX
Connected Line ID Name: APLACEIN, MO
DNID Digits: *8
Language: en
State: Up (6)
Rings: 0
NativeFormats: 0x4 (ulaw)
WriteFormat: 0x4 (ulaw)
ReadFormat: 0x4 (ulaw)
WriteTranscode: No
ReadTranscode: No
1st File Descriptor: 230
Frames in: 3
Frames out: 0
Time to Hangup: 0
Elapsed Time: 70h14m21s
Direct Bridge:
Indirect Bridge:
-- PBX --
Context: from-internal
Extension: 600
Priority: 1
Call Group: 2
Pickup Group: 2
Application: AppDial
Data: (Outgoing Line)
Blocking in: (Not Blocking)
Variables:
RTPAUDIOQOSRTT=minrtt=0.000000;maxrtt=0.000000;avgrtt=0.000000;stdevrtt=0.000000;
RTPAUDIOQOSLOSS=minrxlost=0.000000;maxrxlost=0.000000;avgrxlost=0.000000;stdevrxlost=0.000000;reported_minlost=0.000000;reported_maxlost=0.000000;reported_avglost=0.000000;reported_stdevlost=0.000000;
RTPAUDIOQOSJITTER=minrxjitter=0.000000;maxrxjitter=0.000000;avgrxjitter=0.000000;stdevrxjitter=0.000000;reported_minjitter=0.000000;reported_maxjitter=0.000000;reported_avgjitter=0.000000;reported_stdevjitter=0.000000;
RTPAUDIOQOS=ssrc=755449538;themssrc=0;lp=0;rxjitter=0.000000;rxcount=0;txjitter=0.000000;txcount=0;rlp=0;rtt=0.000000
DIALEDPEERNUMBER=2000
SIPCALLID=7289f5ae18cdbb4f172d0737516b4f1e@10.1.0.10:5060
KEEPCID=TRUE
CALLFILENAME=rg-600-15732805639-20130104-123226-1357324346.2038
FROMEXTEN=1573280XXXX
TIMESTR=20130104-123226
YEAR=2013
MONTH=01
DAY=04
REC_POLICY_MODE=dontcare
REC_STATUS=INITIALIZED
MON_FMT=wav
NODEST=600
BLKVM_CHANNEL=IAX2/VoIP-5963
TTL=64
CALLINGPRES_SV=allowed_not_screened
FROM_DID=XXXXXXXXXX
SIPCALLID=ce2b018b33609c99
SIPDOMAIN=10.1.0.10:5060
SIPURI=sip:2215@10.1.0.51:5060

CDR Variables:
level 1: dnid=
level 1: clid="Unhappy Extension User"
level 1: src=2215
level 1: dst=*8
level 1: dcontext=from-internal
level 1: channel=SIP/2215-000002ed
level 1: start=2013-01-04 12:32:30
level 1: answer=2013-01-04 12:32:30
level 1: duration=252860
level 1: billsec=252860
level 1: disposition=ANSWERED
level 1: amaflags=DOCUMENTATION
level 1: uniqueid=1357324350.2043
level 1: linkedid=1357324350.2043
level 1: sequence=2619

As you can see from the sanitized output above, this channel was stuck all weekend. So then looking over the help, I discovered the command “channel request hangup <channel>’:

asterisk*CLI> channel request hangup SIP/2215-000002ed
Requested Hangup on channel 'SIP/2215-000002ed'

Yay, right? Wrong. Didn’t touch the hung channel. No dice. Until I tried ‘channel redirect <channel> <exten>’:


asterisk*CLI> channel redirect SIP/2215-000002ed 2304
Channel 'SIP/2215-000002ed' successfully redirected to 2304
== Starting SIP/2215-000002ed at from-internal,600,2304 failed so falling back to exten 's'
-- Executing [s@from-internal:1] Macro("SIP/2215-000002ed", "hangupcall") in new stack
-- Executing [s@macro-hangupcall:1] GotoIf("SIP/2215-000002ed", "1?theend") in new stack
-- Goto (macro-hangupcall,s,3)
-- Executing [s@macro-hangupcall:3] ExecIf("SIP/2215-000002ed", "0?Set(CDR(recordingfile)=)") in new stack
-- Executing [s@macro-hangupcall:4] Hangup("SIP/2215-000002ed", "") in new stack
== Spawn extension (macro-hangupcall, s, 4) exited non-zero on 'SIP/2215-000002ed' in macro 'hangupcall'
== Spawn extension (from-internal, s, 1) exited non-zero on 'SIP/2215-000002ed'
-- Executing [h@from-internal:1] Hangup("SIP/2215-000002ed", "") in new stack
== Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/2215-000002ed'

I redirected the channel from the original extension to my own. The original extension is released, my extension is unaffected, and there was much rejoicing. (yay.)

So, the end result is that I still have a hung channel in the system, which I’m sure will remain until I reboot the server. But, the extension is returned to normal, use of the system seems unaffected, and now I have a quick solution to the problem for the next time it occurs. Hope this is useful to someone.

Leave a Reply

Your email address will not be published. Required fields are marked *