Summary:ASTERISK-00057: "501 Not Implemented" replies cause unclean and unexpected SIP channel closure
Reporter:John Todd (jtodd)Labels:
Date Opened:2003-08-07 14:34:34Date Closed:2004-09-25 02:40:14
Versions:Frequency of
Description:When a phone replies to a mid-conversation SIP message with "501 Not Implemented", Asterisk unexpectedly closes the SIP channel in one direction, but not the other.   Asterisk should not close the channel (though why it closes it in only one direction might be worth looking at, as well, to see if that problem is reproduced in other error cases.)


Caller was on a Grandstream, calling into Asterisk (  They had their phone set to send INFO packets when keys were pressed on the keypad.  I had "dtmfmode=info" set for their peer.

The other end of the call (9000) was a Cisco 7960 (

When the GS user hits a key, that SIP message is sent all the way through to the Cisco 7960.  The Cisco says "501 Not Implemented" (I guess the Cisco doesn't grok INFO packets for DTMF) but then Asterisk interprets this response as an end of call and hangs up the channel.  This is non-optimal, obviously, and not expected, since the call should keep running just fine.

Debug output:

-- Executing Dial("SIP/2403664343-132b", "SIP/9000") in new stack
   -- Called 9000
   -- SIP/9000-5563 is ringing
   -- SIP/9000-5563 answered SIP/2403664343-132b
   -- Attempting native bridge of SIP/2403664343-132b and SIP/9000-5563
[voice channel establishes with no problems; conversation ensues]
[a key is pressed here on the Grandstream Phone]
   -- Got SIP response 501 "Not Implemented" back from
 == Spawn extension (compro1, 9000, 1) exited non-zero on 'SIP/2403664343-132b'
   -- Executing Hangup("SIP/2403664343-132b", "") in new stack
 == Spawn extension (compro1, h, 1) exited non-zero on 'SIP/2403664343-132b'

[I fired up tethereal after the call was established to watch what happened when the caller sent the INFO packet]

foo# tethereal port 5060
 0.000000 -> UDP Source port: sip  Destination port: sip
 0.030000 -> SIP Status: 501 Not Implemented

Note that the Cisco ( doesn't hang up the call; it just says "501 Not Implemented".  However, Asterisk takes the 501 error and hangs up the caller's phone (the Grandstream.)  Then, there is no SIP BYE message sent to my 7960, so it's left hanging on a "phantom" call.  In other words the SIP channel has gone away (from Asterisk's perspective) but the 7960 doesn't know the call has been terminated.
Comments:By: Mark Spencer (markster) 2003-08-08 20:52:14

The reason asterisk doesn't send a BYE is clear, because it thought this was a permenant failure.  I've modified chan_sip to (in principle) not freak out on a 501 unless it's on an invite.  Can you confirm the fix works?  Thanks!

By: John Todd (jtodd) 2003-08-11 21:23:44

The patch seems to solve the problem in my limited testing with Grandstream/Cisco phones. Thanks!