[Home]

Summary:ASTERISK-26918: Failed Subscriptions with Expiry=0 Added and not Removed
Reporter:Peter Sokolov (peterdoo)Labels:
Date Opened:2017-04-04 09:00:03Date Closed:
Priority:MinorRegression?No
Status:Open/NewComponents:Resources/res_pjsip_pubsub
Versions:13.14.1 14.3.0 GIT Frequency of
Occurrence
Constant
Related
Issues:
Environment:Attachments:
Description:When there is a hint defined in the dialplan without the endpoint, like for example:
exten => 20,hint,

There are two problems:
1.
When the phone tries to subscribe using the following procedure, asterisk returns "500 Unhandled by dialog usages", however the subscription 313439313239363331303239333235-s29drryc0xcm is still added to the list with Expiry=0 and remains there forever:
{noformat}
SUBSCRIBE sip:[2a00:x:x:x::3]:5060 SIP/2.0
v: SIP/2.0/UDP [2a03:x:x:x:x:x:x:2033]:38047;branch=z9hG4bK-xq7t9dpznq15;rport
f: <sip:14@mydom.com>;tag=z6o87pp1q1
t: <sip:20@mydom.com>;tag=8f19e7a5-7a1c-4ce0-895d-19cfa68434ab;user=phone
i: 313439313239363331303239333235-s29drryc0xcm
CSeq: 63 SUBSCRIBE
Max-Forwards: 70
User-Agent: snomD315/8.9.3.46
m: <sip:14@[2a03:x:x:x:x:x:x:2033]:38047;line=9hfshly5>;reg-id=1
Event: dialog
Accept: application/dialog-info+xml
Authorization: Digest username="14",realm="mydom.com",nonce="1491296310/2488784f3804a67ae5a0ef5cf7c2cb98",uri="sip:20@mydom.com",qop=auth,nc=00000004,cnonce="532c5a80",response="9cf105591e91cd13137587b287eab098",opaque="29538d6c2567dee4",algorithm=MD5
Expires: 600
l: 0

SIP/2.0 500 Unhandled by dialog usages
v: SIP/2.0/UDP [2a03:x:x:x:x:x:x:2033]:38047;rport=38047;received=2a03:x:x:x:x:x:x:2033;branch=z9hG4bK-xq7t9dpznq15
i: 313439313239363331303239333235-s29drryc0xcm
f: <sip:14@mydom.com>;tag=z6o87pp1q1
t: <sip:20@mydom.com>;tag=8f19e7a5-7a1c-4ce0-895d-19cfa68434ab;user=phone
CSeq: 63 SUBSCRIBE
Server: asterisk
l: 0
{noformat}

2.
When the phone then tries to subscribe using the alternative procedure, asterisk returns "200 OK" and the subscription succeeds. It is added to the list with its correct Expiry, hovever remains there forever even when expiration time is reached:
{noformat}
SUBSCRIBE sip:20@mydom.com SIP/2.0
v: SIP/2.0/UDP [2a03:x:x:x:x:x:x:2033]:38047;branch=z9hG4bK-5wcx0sygsfyq;rport
f: <sip:14@mydom.com>;tag=cjddyojr6y
t: <sip:20@mydom.com>;user=phone
i: 313439313239363732333435353736-l9luhb32s4wh
CSeq: 65 SUBSCRIBE
Max-Forwards: 70
User-Agent: snomD315/8.9.3.46
m: <sip:14@[2a03:x:x:x:x:x:x:2033]:38047;line=9hfshly5>;reg-id=1
Event: dialog
Accept: application/dialog-info+xml
Authorization: Digest username="14",realm="mydom.com",nonce="1491296723/d5fd7a6aa9318a82a01deb959883dd4d",uri="sip:20@mydom.com",qop=auth,nc=00000001,cnonce="3ea0d05e",response="f37da1f9b16d2434ea4ed48d896e6232",opaque="4334bf9753276797",algorithm=MD5
Expires: 600
l: 0

SIP/2.0 200 OK
v: SIP/2.0/UDP [2a03:x:x:x:x:x:x:2033]:38047;rport=38047;received=2a03:x:x:x:x:x:x:2033;branch=z9hG4bK-5wcx0sygsfyq
i: 313439313239363732333435353736-l9luhb32s4wh
f: <sip:14@mydom.com>;tag=cjddyojr6y
t: <sip:20@mydom.com>;tag=aa52a882-ebaf-412a-86c5-eaa59906448b;user=phone
CSeq: 65 SUBSCRIBE
Expires: 600
m: <sip:[2a00:x:x:x::3]:5060>
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
k: 100rel, timer, replaces, norefersub
Server: asterisk
l: 0
{noformat}

I am seeing the list of subscriptions growing all the time by about 500 entries each 24 hours.
The workaround I could find is to remove these hints from the dialplan. However then the subscription requests fail and the clients start to retry those subscriptions every few seconds increasing asterisk traffic and load. Extension 20 is a valid extension, however it is not a local endpoint. It is diverted to a mobile number through an external trunk. The phones automatically create a subscription as soon as an extension is assigned to a short dial key.

ASTERISK-26696 has resolved some issues with the subscriptions, however not the two mentioned above which are present in 14.3.0, 14.4.0-rc2.
Comments:By: Asterisk Team (asteriskteam) 2017-04-04 09:00:04.946-0500

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: George Joseph (gjoseph) 2017-04-04 10:24:26.689-0500

Just to confirm, you're using chan_pjsip correct?
Are you using the bundled version?


By: Peter Sokolov (peterdoo) 2017-04-04 15:03:18.956-0500

Yes, using chan_PJSIP, built with
./configure --with-pjproject-bundled

I look at the growing subscriptions list with:
pjsip show subscriptions inbound


By: Leon Wright (techman83) 2019-03-13 21:12:24.047-0500

I have come across this issue when I was discussing this [on the forums|https://community.asterisk.org/t/hint-watchers-increment-indefinitely/78923]. I can confirm it exists from 15.6.x, up to and including Asterisk 16.2.0, built from git and bundled pjproject.

I get the same error:
{code}
SUBSCRIBE sip:x.x.x.95:5060 SIP/2.0
Via: SIP/2.0/UDP x.x.x.104:5060;branch=z9hG4bK975514473
From: "Phone-001" <sip:805EC0017273@somedomain.com.au>;tag=3191372314
To: <sip:6004@somedomain.com.au>;tag=0de9c0a5-7ffc-4116-9290-4bbac5f96259
Call-ID: 0_2914073161@x.x.x.104
CSeq: 3 SUBSCRIBE
Contact: <sip:805EC0017273@x.x.x.104:5060>
Authorization: <redacted>
Accept: application/dialog-info+xml
Max-Forwards: 70
User-Agent: Yealink SIP-T46S 66.83.0.10
Expires: 1800
Event: dialog
Content-Length: 0


SIP/2.0 500 Unhandled by dialog usages
Via: SIP/2.0/UDP x.x.x.104:5060;received=x.x.x.104;branch=z9hG4bK975514473
Call-ID: 0_2914073161@x.x.x.104
From: "Phone-001" <sip:805EC0017273@somedomain.com.au>;tag=3191372314
To: <sip:6004@somedomain.com.au>;tag=0de9c0a5-7ffc-4116-9290-4bbac5f96259
CSeq: 3 SUBSCRIBE
Server: Asterisk PBX 16.2.0
Content-Length:  0
{code}

In production we see a gradual increase memory usage over time, higher in systems that have a lot of subscriptions. Which eventually leads to OOM and a hard lockup. I have worked around this in the interim by setting a custom presence on all endpoints without a device, but I'm assuming memory usage and ever increasing stale subscriptions is undesirable.

{code}
exten => 6004,hint,Custom:NA
{code}