[Home]

Summary:ASTERISK-19163: Got SIP response 400 "Bad Request" after Hangup
Reporter:Adee Mas (adeeadee)Labels:
Date Opened:2012-01-04 03:53:36.000-0600Date Closed:2012-01-17 11:28:12.000-0600
Priority:MajorRegression?
Status:Closed/CompleteComponents:Channels/chan_sip/Interoperability
Versions:1.8.7.2 Frequency of
Occurrence
Constant
Related
Issues:
Environment:CentOS release 5.7, Elastix 2.2.0, Asterisk 1.8.7.2,Attachments:( 0) full-20111229.txt
Description:If asterisk hangs up an open SIP channel incoming from a proxy, the proxy responds with 400 Bad Request at BYE message.

INVITE sip:0311XXXXXX@95.77.93.8:5060;user=phone SIP/2.0
Via: SIP/2.0/UDP 95.77.93.8:5060;branch=z9hG4bKtnidpu002g80uhstg4h1.1
From: 0723XXXXXX <sip:0723XXXXXX@pgw-sip.voip.astralnet.ro:5060;user=phone>;tag=1013365926
To: 0311XXXXXX <sip:0311XXXXXX@78.97.79.104:5060;user=phone>
Call-ID: 407324df-5f589695-2dbb5795-39a2@pgw-sip.voip.astralnet.ro
<-->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 95.77.93.8:5060;branch=z9hG4bKtnidpu002g80uhstg4h1.1;received=95.77.93.8;rport=5060
From: 0723XXXXXX <sip:0723XXXXXX@pgw-sip.voip.astralnet.ro:5060;user=phone>;tag=1013365926
To: 0311XXXXXX <sip:0311XXXXXX@78.97.79.104:5060;user=phone>
Call-ID: 407324df-5f589695-2dbb5795-39a2@pgw-sip.voip.astralnet.ro
<-->
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 95.77.93.8:5060;branch=z9hG4bKtnidpu002g80uhstg4h1.1;received=95.77.93.8;rport=5060
From: 0723XXXXXX <sip:0723XXXXXX@pgw-sip.voip.astralnet.ro:5060;user=phone>;tag=1013365926
To: 0311XXXXXX <sip:0311XXXXXX@78.97.79.104:5060;user=phone>;tag=as42341271
Call-ID: 407324df-5f589695-2dbb5795-39a2@pgw-sip.voip.astralnet.ro
<-->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 95.77.93.8:5060;branch=z9hG4bKtnidpu002g80uhstg4h1.1;received=95.77.93.8;rport=5060
From: 0723XXXXXX <sip:0723XXXXXX@pgw-sip.voip.astralnet.ro:5060;user=phone>;tag=1013365926
To: 0311XXXXXX <sip:0311XXXXXX@78.97.79.104:5060;user=phone>;tag=as42341271
Call-ID: 407324df-5f589695-2dbb5795-39a2@pgw-sip.voip.astralnet.ro
CSeq: 1 INVITE
<-->
ACK sip:0311XXXXXX@95.77.93.8:5060 SIP/2.0
Via: SIP/2.0/UDP 95.77.93.8:5060;branch=z9hG4bKu7per71030cg6ikdo1n0.1
From: 0723XXXXXX <sip:0723XXXXXX@pgw-sip.voip.astralnet.ro:5060;user=phone>;tag=1013365926
To: 0311XXXXXX <sip:0311XXXXXX@78.97.79.104:5060;user=phone>;tag=as42341271
Call-ID: 407324df-5f589695-2dbb5795-39a2@pgw-sip.voip.astralnet.ro
<-->
..playing some audio file.... and then hangup
<-->
BYE sip:0723XXXXXX@95.77.93.8:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP 10.1.14.2:5060;branch=z9hG4bK04d8aaeb;rport
Max-Forwards: 70
From: 0311XXXXXX <sip:0311XXXXXX@78.97.79.104:5060;user=phone>;tag=as42341271
To: 0723XXXXXX <sip:0723XXXXXX@pgw-sip.voip.astralnet.ro:5060;user=phone>;tag=1013365926
Call-ID: 407324df-5f589695-2dbb5795-39a2@pgw-sip.voip.astralnet.ro
<-->
SIP/2.0 400 Bad Request
Via: SIP/2.0/UDP 95.77.93.8:5060;received=10.1.14.2;branch=z9hG4bK04d8aaeb;rport=5060
From: 0311XXXXXX <sip:0311XXXXXX@78.97.79.104:5060;user=phone>;tag=as42341271
To: 0723XXXXXX <sip:0723XXXXXX@pgw-sip.voip.astralnet.ro:5060;user=phone>;tag=1013365926
Call-ID: 407324df-5f589695-2dbb5795-39a2@pgw-sip.voip.astralnet.ro
Comments:By: Adee Mas (adeeadee) 2012-01-04 03:55:19.675-0600

Full log

By: Stefan Schmidt (schmidts) 2012-01-04 05:05:45.701-0600

did the proxy forward the bye to the other side or is the call still active after the BYE?
normally a BYE is absolut, which means it makes not difference what response you get to a BYE the call is dead. Even if you dont get a response after T1X64 (normally 32seconds) the call will be hungup from asterisk.
you can see this in your full log. asterisk receives the 400 response and treated is as an acceptable response to the BYE.

But if this proxy doesnt route the bye forward to the other side then its a problem but IMHO of the proxy.
I have just checked the callid, tags and branch parameter and for me this looks correct what asterisk does.

By: Adee Mas (adeeadee) 2012-01-05 02:17:32.675-0600

No, the proxy does not forward the BYE and the calling party remains connected until it hangs up, even 60 seconds. The SIP proxy provider tells me that the branch tag from via header is malformed because is different than the one in INVITE:

INVITE -  branch=z9hG4bKu7per71030cg6ikdo1n0.1
BYE -  branch=z9hG4bK04d8aaeb

It's normal to be different?



By: David Woolley (davidw) 2012-01-06 05:37:40.257-0600

It is mandatory that they be different.  BYE and INVITE are different transactions:

  The branch parameter value MUST be unique across space and time for
  all requests sent by the UA.  The exceptions to this rule are CANCEL
  and ACK for non-2xx responses.  As discussed below, a CANCEL request
  will have the same value of the branch parameter as the request it
  cancels.  As discussed in Section 17.1.1.3, an ACK for a non-2xx
  response will also have the same branch ID as the INVITE whose
  response it acknowledges.

The manatoryness is new to RFC 3261.  Implemenations against older versions should not be caring about whether it matches.

     The uniqueness property of the branch ID parameter, to facilitate
     its use as a transaction ID, was not part of RFC 2543.

Both quotes from RFC 3261