[Home]

Summary:ASTERISK-00212: Asterisk not following username in URI of Contact header
Reporter:zsprackett (zsprackett)Labels:
Date Opened:2003-09-03 13:22:27Date Closed:2008-01-15 14:33:50.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:This problem manifests itself with the mediatrix 1204 gateway.  It occurs on every PSTN call and ties up an RTP channel.

When a sip phone terminates the call, asterisk sends the BYE to the wrong SIP URI...  Instead of sending it to pstnline2@172.20.16.7 it sends it to 611@172.20.16.7

Unless I'm misuderstanding the rfc asterisk is not properly
handling the Contact header.

Sip debug follows:

[root@carbon root]# asterisk -r
Asterisk CVS-09/01/03-11:21:09, Copyright (C) 1999-2001 Linux Support Services, Inc.
Written by Mark Spencer <markster@linux-support.net>
=========================================================================
Connected to Asterisk CVS-09 currently running on carbon (pid = 21270)
   -- Remote UNIX connection
carbon*CLI> sip debug
SIP Debugging Enabled
Sip read: >
INVITE sip:611@sprackett.com SIP/2.0
Via:SIP/2.0/UDP 66.46.196.156:5060
From:"Zac@Work" <sip:mitel@sprackett.com>;tag=3f55e1cc-1d7-10d8aff2
To:<sip:611@sprackett.com>
Contact:"Zac@Work" <sip:mitel@66.46.196.156>
Call-ID:e1cc0000-d4c439@66.46.196.156
Subject:sip phone call
CSeq:2 INVITE
User-Agent:Mitel-5055-SIP-Phone TST16_12 08000F014455
Allow:INVITE,ACK,CANCEL,BYE,OPTIONS,REFER,NOTIFY
Max-Forwards:70
Content-Type:application/sdp
Content-Length:263

v=0
o=mitel 1062593444 1062593443 IN IP4 66.46.196.156
s=SIP Call
p=+613-592-2122
c=IN IP4 66.46.196.156
t=0 0
m=audio 20050 RTP/AVP 18 0 8 96
a=rtpmap:18 G729/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:96 telephone-event/8000
a=sendrecv

13 headers, 12 lines
Using latest request as basis request
Sending to 66.46.196.156 : 5060 (non-NAT)
Found audio format UNKN
Found audio format UNKN
Found audio format ALAW
Found audio format UNKN
Found description format G729
Found description format PCMU
Found description format PCMA
Found description format telephone-event
Capabilities: us - 524302, them - 268/0, combined - 12
Non-codec capabilities: us - 1, them - 1, combined - 1
Reliably Transmitting (no NAT):
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 66.46.196.156:5060
From: "Zac@Work" <sip:mitel@sprackett.com>;tag=3f55e1cc-1d7-10d8aff2
To: <sip:611@sprackett.com>;tag=as38e73f19
Call-ID: e1cc0000-d4c439@66.46.196.156
CSeq: 2 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Contact:
Proxy-Authenticate: Digest realm="asterisk", nonce="3b29343b"
Content-Length: 0


to 66.46.196.156:5060
Sip read: >
ACK sip:611@sprackett.com SIP/2.0
Via:SIP/2.0/UDP 66.46.196.156:5060
From:"Zac@Work" <sip:mitel@sprackett.com>;tag=3f55e1cc-1d7-10d8aff2
To:<sip:611@sprackett.com>;tag=as38e73f19
Contact:"Zac@Work" <sip:mitel@66.46.196.156>
Call-ID:e1cc0000-d4c439@66.46.196.156
CSeq:2 ACK
User-Agent:Mitel-5055-SIP-Phone TST16_12 08000F014455
Max-Forwards:70
Content-Length:0


10 headers, 0 lines
Sip read: >
INVITE sip:611@sprackett.com SIP/2.0
Via:SIP/2.0/UDP 66.46.196.156:5060
From:"Zac@Work" <sip:mitel@sprackett.com>;tag=3f55e1cc-1d7-10d8aff2
To:<sip:611@sprackett.com>
Contact:"Zac@Work" <sip:mitel@66.46.196.156>
Call-ID:e1cc0000-d4c439@66.46.196.156
Subject:sip phone call
CSeq:3 INVITE
User-Agent:Mitel-5055-SIP-Phone TST16_12 08000F014455
Proxy-Authorization: Digest username="mitel", realm="asterisk", nonce="3b29343b", uri="sip:611@sprackett.com", response="88938fc85f922b75263f65dfd9286c13", opaque="", algorithm=MD5
Allow:INVITE,ACK,CANCEL,BYE,OPTIONS,REFER,NOTIFY
Max-Forwards:70
Content-Type:application/sdp
Content-Length:263

v=0
o=mitel 1062593444 1062593443 IN IP4 66.46.196.156
s=SIP Call
p=+613-592-2122
c=IN IP4 66.46.196.156
t=0 0
m=audio 20050 RTP/AVP 18 0 8 96
a=rtpmap:18 G729/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:96 telephone-event/8000
a=sendrecv

14 headers, 12 lines
Using latest request as basis request
Sending to 66.46.196.156 : 5060 (non-NAT)
Found audio format UNKN
Found audio format UNKN
Found audio format ALAW
Found audio format UNKN
Found description format G729
Found description format PCMU
Found description format PCMA
Found description format telephone-event
Capabilities: us - 524302, them - 268/0, combined - 12
Non-codec capabilities: us - 1, them - 1, combined - 1
Looking for 611 in internal
list_route: hop: <sip:mitel@66.46.196.156>
Transmitting (no NAT):
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 66.46.196.156:5060
From: "Zac@Work" <sip:mitel@sprackett.com>;tag=3f55e1cc-1d7-10d8aff2
To: <sip:611@sprackett.com>;tag=as5e890982
Call-ID: e1cc0000-d4c439@66.46.196.156
CSeq: 3 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Contact: <sip:611@66.11.172.3>
Content-Length: 0


to 66.46.196.156:5060
   -- Executing Dial("SIP/mitel-d160", "SIP/611@mediatrix-1204|20|Tr") in new stack
We're at 172.20.16.1 port 20112
Answering with capability 2
Answering with capability 4
Answering with capability 8
11 headers, 9 lines
Reliably Transmitting:
INVITE sip:611@172.20.16.7 SIP/2.0
Via: SIP/2.0/UDP 172.20.16.1:5060;branch=z9hG4bK49103a45
From: "Zac@Work" <sip:04@172.20.16.1>;tag=as592d4b87
To: <sip:611@172.20.16.7>
Contact: <sip:04@172.20.16.1>
Call-ID: 736d2dcb3433da573130197a6f9624c4@172.20.16.1
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Content-Type: application/sdp
Content-Length: 178

v=0
o=root 22727 22727 IN IP4 172.20.16.1
s=session
c=IN IP4 172.20.16.1
t=0 0
m=audio 20112 RTP/AVP 3 0 8
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
(no NAT) to 172.20.16.7:5060
   -- Called 611@mediatrix-1204
Transmitting (no NAT):
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 66.46.196.156:5060
From: "Zac@Work" <sip:mitel@sprackett.com>;tag=3f55e1cc-1d7-10d8aff2
To: <sip:611@sprackett.com>;tag=as5e890982
Call-ID: e1cc0000-d4c439@66.46.196.156
CSeq: 3 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Contact: <sip:611@66.11.172.3>
Content-Length: 0


to 66.46.196.156:5060
Sip read: >
SIP/2.0 100 Trying
Call-ID: 736d2dcb3433da573130197a6f9624c4@172.20.16.1
CSeq: 102 INVITE
From: "Zac@Work" <sip:04@172.20.16.1>;tag=as592d4b87
To: <sip:611@172.20.16.7>;tag=3be40ad0-c9c9ff1e
Via: SIP/2.0/UDP 172.20.16.1:5060;branch=z9hG4bK49103a45
Content-Length: 0


7 headers, 0 lines
Sip read: > sip
SIP/2.0 200 OK
Call-ID: 736d2dcb3433da573130197a6f9624c4@172.20.16.1
CSeq: 102 INVITE
From: "Zac@Work" <sip:04@172.20.16.1>;tag=as592d4b87
To: <sip:611@172.20.16.7>;tag=3be40ad0-c9c9ff1e
Via: SIP/2.0/UDP 172.20.16.1:5060;branch=z9hG4bK49103a45
Content-Length: 148
Content-Type: application/sdp
Contact: "PSTN LINE 2" <sip:pstnline2@172.20.16.7:5060>
Allow: INVITE, ACK, BYE, CANCEL, REFER, NOTIFY
Supported: replaces

v=0
o=MxSIP 0 0 IN IP4 172.20.16.7
s=SIP Call
c=IN IP4 172.20.16.7
t=0 0
m=audio 5006 RTP/AVP 0 8
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000

11 headers, 8 lines
Found audio format UNKN
Found audio format ALAW
Found description format PCMU
Found description format PCMA
Capabilities: us - 524302, them - 12/0, combined - 12
Non-codec capabilities: us - 1, them - 0, combined - 0
list_route: hop: <sip:pstnline2@172.20.16.7:5060>
set_destination: Parsing <sip:pstnline2@172.20.16.7:5060> for address/port to send to
set_destination: set destination to 172.20.16.7, port 5060
Transmitting:
ACK sip:611@172.20.16.7 SIP/2.0
Via: SIP/2.0/UDP 172.20.16.1:5060;branch=z9hG4bK49103a45
From: "Zac@Work" <sip:04@172.20.16.1>;tag=as592d4b87
To: <sip:611@172.20.16.7>;tag=3be40ad0-c9c9ff1e
Contact: <sip:04@172.20.16.1>
Call-ID: 736d2dcb3433da573130197a6f9624c4@172.20.16.1
CSeq: 102 ACK
User-Agent: Asterisk PBX
Content-Length: 0

(no NAT) to 172.20.16.7:5060
   -- SIP/mediatrix-1204-1ce5 answered SIP/mitel-d160
We're at 66.11.172.3 port 20824
Answering with capability 4
Answering with capability 8
Reliably Transmitting (no NAT):
SIP/2.0 200 OK
Via: SIP/2.0/UDP 66.46.196.156:5060
From: "Zac@Work" <sip:mitel@sprackett.com>;tag=3f55e1cc-1d7-10d8aff2
To: <sip:611@sprackett.com>;tag=as5e890982
Call-ID: e1cc0000-d4c439@66.46.196.156
CSeq: 3 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Contact: <sip:611@66.11.172.3>
Content-Type: application/sdp
Content-Length: 155

v=0
o=root 22727 22727 IN IP4 66.11.172.3
s=session
c=IN IP4 66.11.172.3
t=0 0
m=audio 20824 RTP/AVP 0 8
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000

to 66.46.196.156:5060
   -- Attempting native bridge of SIP/mitel-d160 and SIP/mediatrix-1204-1ce5
Sip read:
ACK sip:611@66.11.172.3 SIP/2.0
Via:SIP/2.0/UDP 66.46.196.156:5060
From:"Zac@Work" <sip:mitel@sprackett.com>;tag=3f55e1cc-1d7-10d8aff2
To:<sip:611@sprackett.com>;tag=as5e890982
Contact:"Zac@Work" <sip:mitel@66.46.196.156>
Call-ID:e1cc0000-d4c439@66.46.196.156
CSeq:3 ACK
User-Agent:Mitel-5055-SIP-Phone TST16_12 08000F014455
Max-Forwards:70
Content-Length:0


10 headers, 0 lines
Sip read:
BYE sip:611@66.11.172.3 SIP/2.0
Via:SIP/2.0/UDP 66.46.196.156:5060
From:"Zac@Work" <sip:mitel@sprackett.com>;tag=3f55e1cc-1d7-10d8aff2
To:<sip:611@sprackett.com>;tag=as5e890982
Contact:"Zac@Work" <sip:mitel@66.46.196.156>
Call-ID:e1cc0000-d4c439@66.46.196.156
CSeq:4 BYE
User-Agent:Mitel-5055-SIP-Phone TST16_12 08000F014455
Max-Forwards:70
Content-Length:0


10 headers, 0 lines
Sending to 66.46.196.156 : 5060 (non-NAT)
Transmitting (no NAT):
SIP/2.0 200 OK
Via: SIP/2.0/UDP 66.46.196.156:5060
From: "Zac@Work" <sip:mitel@sprackett.com>;tag=3f55e1cc-1d7-10d8aff2
To: <sip:611@sprackett.com>;tag=as5e890982
Call-ID: e1cc0000-d4c439@66.46.196.156
CSeq: 4 BYE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Contact: <sip:611@66.11.172.3>
Content-Length: 0


to 66.46.196.156:5060
set_destination: Parsing <sip:pstnline2@172.20.16.7:5060> for address/port to send to
set_destination: set destination to 172.20.16.7, port 5060
Reliably Transmitting:
BYE sip:611@172.20.16.7 SIP/2.0
Via: SIP/2.0/UDP 172.20.16.1:5060;branch=z9hG4bK49103a45
From: "Zac@Work" <sip:04@172.20.16.1>;tag=as592d4b87
To: <sip:611@172.20.16.7>;tag=3be40ad0-c9c9ff1e
Contact: <sip:04@172.20.16.1>
Call-ID: 736d2dcb3433da573130197a6f9624c4@172.20.16.1
CSeq: 103 BYE
User-Agent: Asterisk PBX
Content-Length: 0

(no NAT) to 172.20.16.7:5060
 == Spawn extension (internal, 611, 1) exited non-zero on 'SIP/mitel-d160'
Sip read:
SIP/2.0 404 Not Found
Call-ID: 736d2dcb3433da573130197a6f9624c4@172.20.16.1
CSeq: 103 BYE
From: "Zac@Work" <sip:04@172.20.16.1>;tag=as592d4b87
To: <sip:611@172.20.16.7>;tag=3be40ad0-c9c9ff1e
Via: SIP/2.0/UDP 172.20.16.1:5060;branch=z9hG4bK49103a45
Content-Length: 0


7 headers, 0 lines
   -- Got SIP response 404 "Not Found" back from 172.20.16.7

No such command 'sip' (type 'help' for help)
carbon*CLI> sip no debug
SIP Debugging Disabled

The end result is that asterisk is sending the bye to the wrong sip URI and receiving a 404 response.

This causes asterisk to keep the RTP channel open even after the call is supposed to be torn down as seen here:

carbon*CLI> sip show channels
Peer             User/ANR    Call ID      Seq (Tx/Rx)  Lag      Jitter  Format
172.20.16.7      (None)      736d2dcb343  00101/201153740  00000ms  0000ms  UNKN
172.20.16.7      (None)      4c98f793676  00101/1293907020  00000ms  0000ms  UNKN
172.20.16.7      (None)      4be294900ba  00101/1744544499  00000ms  0000ms  UNKN
3 active SIP channel(s)

The PSTN Gateway also keeps the connection active as it hasn't received a BYE request.
Comments:By: Mark Spencer (markster) 2003-09-03 16:44:56

Have you tried "username=foo" in the friend/peer definition?

By: zsprackett (zsprackett) 2003-09-03 17:17:17

Can't set username=foo as the contact username is unique to a port and is passed back in the contact header.

Yanked from sip debug posted above:

Sip read: > sip
SIP/2.0 200 OK
Call-ID: 736d2dcb3433da573130197a6f9624c4@172.20.16.1
CSeq: 102 INVITE
From: "Zac@Work" <sip:04@172.20.16.1>;tag=as592d4b87
To: <sip:611@172.20.16.7>;tag=3be40ad0-c9c9ff1e
Via: SIP/2.0/UDP 172.20.16.1:5060;branch=z9hG4bK49103a45
Content-Length: 148
Content-Type: application/sdp
Contact: "PSTN LINE 2" <sip:pstnline2@172.20.16.7:5060>
Allow: INVITE, ACK, BYE, CANCEL, REFER, NOTIFY
Supported: replaces

By: Mark Spencer (markster) 2003-09-03 23:39:49

Try latest CVS.  I've made it re-extract the URI out of the contact in each reply.

By: zsprackett (zsprackett) 2003-09-03 23:55:44

Works perfectly.  Thank you very much for being so responsive.  I'm extremely impressed by the support for opensource users of asterisk from digium.

You guys rock!

By: Mark Spencer (markster) 2003-09-04 00:09:01

Fixed in CVS

By: Digium Subversion (svnbot) 2008-01-15 14:33:50.000-0600

Repository: asterisk
Revision: 1473

U   trunk/apps/Makefile
U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r1473 | markster | 2008-01-15 14:33:50 -0600 (Tue, 15 Jan 2008) | 2 lines

Take URI from responses (bug ASTERISK-212)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=1473