[Home]

Summary:ASTERISK-27685: res_pjsip_dialog_info_body_generator: Dialog id is reused after transitioning to terminated
Reporter:Cyrille Demaret (ziki)Labels:pjsip
Date Opened:2018-02-16 15:17:45.000-0600Date Closed:
Priority:MinorRegression?
Status:Open/NewComponents:Resources/res_pjsip_dialog_info_body_generator
Versions:15.2.1 Frequency of
Occurrence
Constant
Related
Issues:
is duplicated byASTERISK-27682 PJSIP outbound-publish, ETag and Event: dialog
Environment:Attachments:( 0) Publish.txt
Description:Asterisk is sending a PUBLISH with a "early" state with a SIP-If-Match for an already terminated dialog. According to the RFC 4235, this shouldn't happens.

Asterisk send :

PUBLISH sip:201@192.168.100.37 SIP/2.0
Via: SIP/2.0/UDP 192.168.100.37:5080;rport;branch=z9hG4bKPj1794e605-4e31-4b85-a5c8-6e2d6b04896c
From: <sip:201@mydomain.com>;tag=5d7d5883-8dbe-4039-a58a-e6a7f97211a9
To: <sip:201@mydomain.com>
Call-ID: 23b4c0df-ccf6-4325-912a-7396a0d169a4
CSeq: 39221 PUBLISH
Event: dialog
Expires: 180
Max-Forwards: 70
User-Agent: Asterisk PBX 15.2.1
Content-Type: application/dialog-info+xml
Content-Length:   247

<?xml version="1.0" encoding="UTF-8"?>
<dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="15" state="full" entity="sip:201@mydomain.com">
<dialog id="201" direction="recipient">
 <state>early</state>
</dialog>
</dialog-info>

The presence server replies :

SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.100.37:5080;rport=5080;branch=z9hG4bKPj1794e605-4e31-4b85-a5c8-6e2d6b04896c;received=192.168.100.37
From: <sip:201@mydomain.com>;tag=5d7d5883-8dbe-4039-a58a-e6a7f97211a9
To: <sip:201@mydomain.com>;tag=b596189c6de9c38f624fd84638f43be6-dec6
Call-ID: 23b4c0df-ccf6-4325-912a-7396a0d169a4
CSeq: 39221 PUBLISH
Expires: 170
SIP-ETag: a.1518814633.30600.10.0
Server: kamailio (5.0.5 (x86_64/linux))
Content-Length: 0

When the call is done, Asterisk send another PUBLISH telling that the call is terminated :

PUBLISH sip:201@192.168.100.37 SIP/2.0
Via: SIP/2.0/UDP 192.168.100.37:5080;rport;branch=z9hG4bKPj537dc03b-eb54-4e99-b221-beb7352be34f
From: <sip:201@mydomain.com>;tag=71c848f9-a9e7-4e63-a990-bc604fdcada5
To: <sip:201@mydomain.com>
Call-ID: 23b4c0df-ccf6-4325-912a-7396a0d169a4
CSeq: 39222 PUBLISH
Event: dialog
SIP-If-Match: a.1518814633.30600.10.0
Expires: 180
Max-Forwards: 70
User-Agent: Asterisk PBX 15.2.1
Content-Type: application/dialog-info+xml
Content-Length:   230

<?xml version="1.0" encoding="UTF-8"?>
<dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="17" state="full" entity="sip:201@mydomain.com">
<dialog id="201">
 <state>terminated</state>
</dialog>
</dialog-info>

The presence server replies :

SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.100.37:5080;rport=5080;branch=z9hG4bKPj537dc03b-eb54-4e99-b221-beb7352be34f;received=192.168.100.37
From: <sip:201@mydomain.com>;tag=71c848f9-a9e7-4e63-a990-bc604fdcada5
To: <sip:201@mydomain.com>;tag=b596189c6de9c38f624fd84638f43be6-9a38
Call-ID: 23b4c0df-ccf6-4325-912a-7396a0d169a4
CSeq: 39222 PUBLISH
Expires: 170
SIP-ETag: a.1518814633.30590.9.1
Server: kamailio (5.0.5 (x86_64/linux))
Content-Length: 0

If a new call is made before the expiration, Asterisk reuse the same ETag:

PUBLISH sip:201@192.168.100.37 SIP/2.0
Via: SIP/2.0/UDP 192.168.100.37:5080;rport;branch=z9hG4bKPj95f84975-2ec7-4487-a038-e93098b8373d
From: <sip:201@mydomain.com>;tag=58c0292a-56d1-4dde-9824-3fa9f2153863
To: <sip:201@mydomain.com>
Call-ID: 23b4c0df-ccf6-4325-912a-7396a0d169a4
CSeq: 39223 PUBLISH
Event: dialog
SIP-If-Match: a.1518814633.30590.9.1
Expires: 180
Max-Forwards: 70
User-Agent: Asterisk PBX 15.2.1
Content-Type: application/dialog-info+xml
Content-Length:   247

<?xml version="1.0" encoding="UTF-8"?>
<dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="19" state="full" entity="sip:201@mydomain.com">
<dialog id="201" direction="recipient">
 <state>early</state>
</dialog>
</dialog-info>
Comments:By: Asterisk Team (asteriskteam) 2018-02-16 15:17:45.889-0600

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: Benjamin Keith Ford (bford) 2018-02-20 15:42:58.363-0600

[~ziki], do you have a log file where you see the above issue happening that you could attach to the issue?

By: Cyrille Demaret (ziki) 2018-03-12 05:38:50.645-0500

I hope that's what you need.

asterisk1*CLI> devstate change Custom:switch1 NOT_INUSE
Changing switch1 to NOT_INUSE
asterisk1*CLI> devstate change Custom:switch1 INUSE    
Changing switch1 to INUSE
asterisk1*CLI> devstate change Custom:switch1 NOT_INUSE
Changing switch1 to NOT_INUSE

By: Joshua C. Colp (jcolp) 2018-03-12 07:57:35.625-0500

The underlying problem here is that dialog-info+xml is used to convey dialog state information, while we fake it for use for presence. In the case of dialogs you can't transition out of terminated. This seems tolerated by everything except for Kamailio. The fix would be to change the dialog id when we transition into terminated so that the next update has a unique dialog.