When a client sends a SUBSCRIBE with Expires: 0, Kamailio responds correctly with a "202 OK".

But then Kamailio sends a NOTIFY to the same client with "Subscription-State: terminated;reason=timeout".

The client rejects this NOTIFY with a "481 Dialog/Transaction Does Not Exist".

Why does Kamailio send this NOTIFY, and is there any way to fix or disable it because it's always rejected by the client?

The client is IMSDroid, and Kamailio is 5.2.2 with a default configuration.


Packet 1 = Client sending SUBSCRIBE with Expires: 0

SUBSCRIBE sip:X.X.X.X:443;transport=tcp SIP/2.0
Via: SIP/2.0/TCP 192.168.0.21:45336;branch=z9hG4bK-670576127
From: <sip:username@domain.com>;tag=1372208921
To: <sip:kamailio.domain.com>;tag=c4eb72dabf44e7588b972bd3b454ea11-0cd6
Contact: <sip:username@192.168.0.21:45336;transport=tcp>
Call-ID: e8cffa8f-948d-eb99-69ca-c9f18bdf11a0
CSeq: 1321654295 SUBSCRIBE
Expires: 0
Content-Length: 299
Max-Forwards: 70
Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER
Accept: application/pidf+xml
Event: presence


Packet 2 = Kamailio responding with 202 OK

SIP/2.0 202 OK
Via: SIP/2.0/TCP 192.168.0.21:45336;branch=z9hG4bK-670576127
From: <sip:username@domain.com>;tag=1372208921
To: <sip:kamailio@domain.com>;tag=c4eb72dabf44e7588b972bd3b454ea11-0cd6
Call-ID: e8cffa8f-948d-eb99-69ca-c9f18bdf11a0
CSeq: 1321654295 SUBSCRIBE
Expires: 0
Contact: <sip:X.X.X.X:443;transport=tcp>
Server: kamailio (5.2.2 (x86_64/linux))
Content-Length: 0


Packet 3 = Kamailio sending a NOTIFY

NOTIFY sip:username@192.168.0.21:45336;transport=tcp SIP/2.0
Via: SIP/2.0/TCP X.X.X.X:443;branch=z9hG4bKefe7.5f8ec435000000000000000000000000.0
To: <sip:username@domain.com>;tag=1372208921
From: <sip:kamailio@domain.com>;tag=c4eb72dabf44e7588b972bd3b454ea11-0cd6
CSeq: 3 NOTIFY
Call-ID: e8cffa8f-948d-eb99-69ca-c9f18bdf11a0
Content-Length: 0
Max-Forwards: 70
Event: presence
Contact: <sip:X.X.X.X:443;transport=tcp>
Subscription-State: terminated;reason=timeout


Packet 4 = Client responding to the NOTIFY with "481 Dialog/Transaction Does Not Exist"

SIP/2.0 481 Dialog/Transaction Does Not Exist
Via: SIP/2.0/TCP X.X.X.X:443;branch=z9hG4bKefe7.5f8ec435000000000000000000000000.0
From: <sip:kamailio@domain.com>;tag=c4eb72dabf44e7588b972bd3b454ea11-0cd6
To: <sip:username@domain.com>;tag=1372208921
Call-ID: e8cffa8f-948d-eb99-69ca-c9f18bdf11a0
CSeq: 3 NOTIFY
Content-Length: 0


There are two entries in the Kamailio log:

INFO: {1 1321654295 SUBSCRIBE e8cffa8f-948d-eb99-69ca-c9f18bdf11a0} presence [notify.c:1614]: send_notify_request(): NOTIFY sip:username@domain.com via sip:Y.Y.Y.Y:45336;transport=tcp on behalf of sip:kamailio.domain.com for event presence : e8cffa8f-948d-eb99-69ca-c9f18bdf11a0

ERROR: {2 3 NOTIFY e8cffa8f-948d-eb99-69ca-c9f18bdf11a0} presence [subscribe.c:497]: delete_subs(): Failed to delete subscription from memory [slot: 174 ev: sip:kamailio.domain.com pu: presence ci: e8cffa8f-948d-eb99-69ca-c9f18bdf11a0 ft: 1372208921 tt: c4eb72dabf44e7588b972bd3b454ea11-0cd6]


These are the presence settings in the Kamailio config file:

#!ifdef WITH_PRESENCE
# ----- presence params -----
modparam("presence", "db_url", DBURL)
modparam("presence", "send_fast_notify", 0)

# ----- presence_xml params -----
modparam("presence_xml", "db_url", DBURL)
modparam("presence_xml", "force_active", 1)
modparam("presence_xml", "force_dummy_presence", 0)
#!endif


Appreciate your help.