[SR-Users] pua_usrloc, PUBLISH not send when contact is deleted or expires

Giacomo Vacca Giacomo.Vacca at truphone.com
Thu Jan 19 11:49:17 CET 2012


Ah thanks Daniel,
So I had a wrong expectation on the behaviour of pua_usrloc.
It does make sense that the PUBLISH already carries its expiry and so the expiration moment is implicit and should/can be handled elsewhere.

I think what confused me were two things: the pua_usrloc documentation and the fact that pua_usrloc does register for EXPIRE callbacks with usrloc.

I'm referring to:
"The pua_usrloc module is the connector between the usrloc and pua modules. It creates the environment to send PUBLISH requests for user location records, on specific events (e.g., when new record is added in usrloc, a PUBLISH with status open (online) is issued; when expires, it sends closed (offline))."

Thanks for clarifying this.

Regards,
Giacomo

From: Daniel-Constantin Mierla [mailto:miconda at gmail.com]
Sent: 19 January 2012 10:37
To: SIP Router - Kamailio (OpenSER) and SIP Express Router (SER) - Users Mailing List
Cc: Giacomo Vacca
Subject: Re: [SR-Users] pua_usrloc, PUBLISH not send when contact is deleted or expires

Hello,

On 1/19/12 11:22 AM, Giacomo Vacca wrote:
Hi Daniel,
Thanks for your feedback. Yes, using mysql and enabling presence made it work for un-registrations too.
Just for the purpose of this scenario I'm sending the PUBLISH back to the same entity, and it's being handled as a presentity.

I still have a missing piece though (which is in fact the reason for this configuration): having PUBLISH requests triggered by the expiration of a contact.

When a contact expires, pua_usrloc is now logging:

Jan 19 10:12:03 debian6 /usr/sbin/kamailio[4359]: INFO: pua_usrloc [ul_publish.c:211]: should not send ul publish

(please see below for traces and details).

Since I'm marking a registration with pua_set_publish(), why is that flag not seen as true when usrloc fires an EXPIRE callback?

I've tried marking every REGISTER request with pua_set_publish(), and not just the first one, before calling save("location") but the result was the same.

the PUBLISH for registration expiration does not make sense, as PUBLISH has also an expire interval, so the record in the presence server should expire at the same time. A publish with update state to close will eventually hit the presence server when there is no record for it. Presence server will send notifications when the record in its table expires.

Cheers,
Daniel




Thanks again,
Giacomo


First registration and PUBLISH:

U 2012/01/19 10:08:46.867546 192.168.142.1:13752 -> 192.168.142.131:5060
REGISTER sip:192.168.142.131 SIP/2.0.
Via: SIP/2.0/UDP 192.168.142.1:13752;branch=z9hG4bK-d8754z-6dcc94d7866db11d-1---d8754z-;rport.
Max-Forwards: 70.
Contact: <sip:2070109 at 192.168.142.1:13752;rinstance=f949af25d45274c6><sip:2070109 at 192.168.142.1:13752;rinstance=f949af25d45274c6>.
To: "GV_XLite"<sip:2070109 at 192.168.142.131><sip:2070109 at 192.168.142.131>.
From: "GV_XLite"<sip:2070109 at 192.168.142.131><sip:2070109 at 192.168.142.131>;tag=0c957d3f.
Call-ID: ZmI1OGFhMzIyYTExNTYzOTIzNDRiZmI1NjQzZGZhZDI..
CSeq: 1 REGISTER.
Expires: 3600.
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO.
User-Agent: X-Lite 4 release 4.1 stamp 63214.
Content-Length: 0.
.


U 2012/01/19 10:08:46.870154 192.168.142.131:5060 -> 127.0.0.1:5060
PUBLISH sip:2070109 at 127.0.0.1 SIP/2.0.
Via: SIP/2.0/UDP 192.168.142.131;branch=z9hG4bK0722.77d94013.0.
To: sip:2070109 at 127.0.0.1.
From: sip:2070109 at 127.0.0.1;tag=533cb9e91f4b999cf76861cbb9ed54ed-168c.
CSeq: 10 PUBLISH.
Call-ID: 7fedefec-4355 at 127.0.0.1<mailto:7fedefec-4355 at 127.0.0.1>.
Content-Length: 338.
User-Agent: kamailio (3.2.1 (i386/linux)).
Max-Forwards: 70.
Event: presence.
Expires: 61.
Content-Type: application/pidf+xml.
.
<?xml version="1.0"?>
<presence xmlns="urn:ietf:params:xml:ns:pidf" xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model" xmlns:rpid="urn:ietf:params:xml:ns:pidf:rpid" xmlns:c="urn:ietf:params:xml:ns:pidf:cipid" entity="2070109 at 127.0.0.1"<mailto:2070109 at 127.0.0.1>>
  <tuple id="0xb727ad14">
    <status>
      <basic>open</basic>
    </status>
  </tuple>
</presence>


U 2012/01/19 10:08:46.872917 127.0.0.1:5060 -> 192.168.142.131:5060
SIP/2.0 200 OK.
Via: SIP/2.0/UDP 192.168.142.131;branch=z9hG4bK0722.77d94013.0.
To: sip:2070109 at 127.0.0.1;tag=a6a1c5f60faecf035a1ae5b6e96e979a-106f.
From: sip:2070109 at 127.0.0.1;tag=533cb9e91f4b999cf76861cbb9ed54ed-168c.
CSeq: 10 PUBLISH.
Call-ID: 7fedefec-4355 at 127.0.0.1<mailto:7fedefec-4355 at 127.0.0.1>.
Expires: 60.
SIP-ETag: a.1326967203.4352.2.0.
Server: kamailio (3.2.1 (i386/linux)).
Content-Length: 0.
.


U 2012/01/19 10:08:46.874271 192.168.142.131:5060 -> 192.168.142.1:13752
SIP/2.0 200 OK.
Via: SIP/2.0/UDP 192.168.142.1:13752;branch=z9hG4bK-d8754z-6dcc94d7866db11d-1---d8754z-;rport=13752.
To: "GV_XLite"<sip:2070109 at 192.168.142.131><sip:2070109 at 192.168.142.131>;tag=b27e1a1d33761e85846fc98f5f3a7e58.4cd5.
From: "GV_XLite"<sip:2070109 at 192.168.142.131><sip:2070109 at 192.168.142.131>;tag=0c957d3f.
Call-ID: ZmI1OGFhMzIyYTExNTYzOTIzNDRiZmI1NjQzZGZhZDI..
CSeq: 1 REGISTER.
Contact: <sip:2070109 at 192.168.142.1:13752;rinstance=f949af25d45274c6><sip:2070109 at 192.168.142.1:13752;rinstance=f949af25d45274c6>;expires=60.
Server: kamailio (3.2.1 (i386/linux)).
Content-Length: 0.
.


Registration refresh and PUBLISH:

U 2012/01/19 10:09:41.599554 192.168.142.1:13752 -> 192.168.142.131:5060
REGISTER sip:192.168.142.131 SIP/2.0.
Via: SIP/2.0/UDP 192.168.142.1:13752;branch=z9hG4bK-d8754z-4e5bc39865a12b22-1---d8754z-;rport.
Max-Forwards: 70.
Contact: <sip:2070109 at 192.168.142.1:13752;rinstance=f949af25d45274c6><sip:2070109 at 192.168.142.1:13752;rinstance=f949af25d45274c6>.
To: "GV_XLite"<sip:2070109 at 192.168.142.131><sip:2070109 at 192.168.142.131>.
From: "GV_XLite"<sip:2070109 at 192.168.142.131><sip:2070109 at 192.168.142.131>;tag=0c957d3f.
Call-ID: ZmI1OGFhMzIyYTExNTYzOTIzNDRiZmI1NjQzZGZhZDI..
CSeq: 2 REGISTER.
Expires: 3600.
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO.
User-Agent: X-Lite 4 release 4.1 stamp 63214.
Content-Length: 0.
.


U 2012/01/19 10:09:41.605967 192.168.142.131:5060 -> 127.0.0.1:5060
PUBLISH sip:2070109 at 127.0.0.1 SIP/2.0.
Via: SIP/2.0/UDP 192.168.142.131;branch=z9hG4bK568c.a38addc4.0.
To: sip:2070109 at 127.0.0.1.
From: sip:2070109 at 127.0.0.1;tag=533cb9e91f4b999cf76861cbb9ed54ed-001d.
CSeq: 10 PUBLISH.
Call-ID: 7fedefed-4357 at 127.0.0.1<mailto:7fedefed-4357 at 127.0.0.1>.
Content-Length: 0.
User-Agent: kamailio (3.2.1 (i386/linux)).
Max-Forwards: 70.
Event: presence.
Expires: 61.
SIP-If-Match: a.1326967203.4352.2.0.
.


U 2012/01/19 10:09:41.617174 127.0.0.1:5060 -> 192.168.142.131:5060
SIP/2.0 200 OK.
Via: SIP/2.0/UDP 192.168.142.131;branch=z9hG4bK568c.a38addc4.0.
To: sip:2070109 at 127.0.0.1;tag=a6a1c5f60faecf035a1ae5b6e96e979a-70c8.
From: sip:2070109 at 127.0.0.1;tag=533cb9e91f4b999cf76861cbb9ed54ed-001d.
CSeq: 10 PUBLISH.
Call-ID: 7fedefed-4357 at 127.0.0.1<mailto:7fedefed-4357 at 127.0.0.1>.
Expires: 60.
SIP-ETag: a.1326967203.4351.2.1.
Server: kamailio (3.2.1 (i386/linux)).
Content-Length: 0.
.


U 2012/01/19 10:09:41.620221 192.168.142.131:5060 -> 192.168.142.1:13752
SIP/2.0 200 OK.
Via: SIP/2.0/UDP 192.168.142.1:13752;branch=z9hG4bK-d8754z-4e5bc39865a12b22-1---d8754z-;rport=13752.
To: "GV_XLite"<sip:2070109 at 192.168.142.131><sip:2070109 at 192.168.142.131>;tag=b27e1a1d33761e85846fc98f5f3a7e58.9769.
From: "GV_XLite"<sip:2070109 at 192.168.142.131><sip:2070109 at 192.168.142.131>;tag=0c957d3f.
Call-ID: ZmI1OGFhMzIyYTExNTYzOTIzNDRiZmI1NjQzZGZhZDI..
CSeq: 2 REGISTER.
Contact: <sip:2070109 at 192.168.142.1:13752;rinstance=f949af25d45274c6><sip:2070109 at 192.168.142.1:13752;rinstance=f949af25d45274c6>;expires=60.
Server: kamailio (3.2.1 (i386/linux)).
Content-Length: 0.
.

Now pua table contains:

> SELECT * FROM pua\G
*************************** 1. row ***************************
             id: 12
       pres_uri: sip:2070109 at 127.0.0.1
        pres_id: UL_PUBLISH.ZmI1OGFhMzIyYTExNTYzOTIzNDRiZmI1NjQzZGZhZDI.
          event: 1
        expires: 1326967841
desired_expires: 1326967841
           flag: 1
           etag: a.1326967203.4351.2.1
       tuple_id: 0xb727ad14
    watcher_uri:
        call_id:
         to_tag:
       from_tag:
           cseq: 0
   record_route:
        contact:
 remote_contact:
        version: 1
  extra_headers:
1 row in set (0.00 sec)

Then I kill the client, and wait for the contact expiration. This is logged (debug level 4), and no PUBLISH issued:

Jan 19 10:12:03 debian6 /usr/sbin/kamailio[4359]: DEBUG: usrloc [ul_callback.h:89]: contact=0xb4db7638, callback type 8/8, id 1 entered
Jan 19 10:12:03 debian6 /usr/sbin/kamailio[4359]: INFO: pua_usrloc [ul_publish.c:211]: should not send ul publish
Jan 19 10:12:03 debian6 /usr/sbin/kamailio[4359]: DEBUG: usrloc [urecord.c:246]: Binding '2070109','sip:2070109 at 192.168.142.1:13752;rinstance=f949af25d45274c6' has expired






From: Daniel-Constantin Mierla [mailto:miconda at gmail.com]
Sent: 18 January 2012 21:17
To: SIP Router - Kamailio (OpenSER) and SIP Express Router (SER) - Users Mailing List
Cc: Giacomo Vacca
Subject: Re: [SR-Users] pua_usrloc, PUBLISH not send when contact is deleted or expires

Hello,

On 1/18/12 12:50 PM, Giacomo Vacca wrote:
Thanks Daniel,

> can you switch to nightly builds from branch 3.2 just to be sure it is not related to something that was fixed since 3.2.0 was released?

I've switched and now have installed 3.2.1, and moved to sqlite too.
I've spent some time to verify a change in behaviour, but I'm observing the same.
Registering with a different device (e.g. sipp) gives the same result.

I tested with default config, where I enabled mysql and presence service, plus loaded and configured pua and pua_usrloc similar to your snippet. All seemed ok, I pasted the ngrep to the end of my reply, first for register and then for un-register.

In your case, is the publish for registration getting 200ok?


> db_text is not really suitable for dealing with large data and write to disk when the sip server is shut down, maybe it is better to use db_sqlite for this case, at least you can check the content of the db table with sqlite tools.

My current goal is a proof of concept so I'm not concerned about performances - am I right in thinking that the problem in finding the presentity in pua's hash table is independent from the DB usage, or may it have an impact?

Well, the issue of using db_text might be with storing the xml documents (publish body) in presence table. db_text keeps a raw per line in a text file.

Cheers,
Daniel


U 2012/01/18 21:52:40.729795 127.0.0.1:57982 -> 127.0.0.1:5060
REGISTER sip:127.0.0.1 SIP/2.0.
Via: SIP/2.0/UDP 127.0.1.1:5080;branch=z9hG4bK.29f7bb6d;rport;alias.
From: sip:test at 127.0.0.1;tag=41f6277b.
To: sip:test at 127.0.0.1.
Call-ID: 1106651003 at 127.0.1.1<mailto:1106651003 at 127.0.1.1>.
CSeq: 1 REGISTER.
Content-Length: 0.
Max-Forwards: 70.
User-Agent: sipsak 0.9.6.
Expires: 70.
Contact: sip:test at 127.0.1.1:5080.
.


U 2012/01/18 21:52:40.732876 127.0.0.1:5060 -> 127.0.0.1:5060
PUBLISH sip:test at 127.0.0.1 SIP/2.0.
Via: SIP/2.0/UDP 127.0.0.1;branch=z9hG4bK25a7.88a7c0d5.0.
To: sip:test at 127.0.0.1.
From: sip:test at 127.0.0.1;tag=533cb9e91f4b999cf76861cbb9ed54ed-76e3.
CSeq: 10 PUBLISH.
Call-ID: 53162b3d3a4cff50-20164 at 127.0.0.1<mailto:53162b3d3a4cff50-20164 at 127.0.0.1>.
Content-Length: 339.
User-Agent: kamailio (3.3.0-dev5 (x86_64/linux)).
Max-Forwards: 70.
Event: presence.
Expires: 71.
Content-Type: application/pidf+xml.
.
<?xml version="1.0"?>
<presence xmlns="urn:ietf:params:xml:ns:pidf" xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model" xmlns:rpid="urn:ietf:params:xml:ns:pidf:rpid" xmlns:c="urn:ietf:params:xml:ns:pidf:cipid" entity="test at 127.0.0.1"<mailto:test at 127.0.0.1>>
  <tuple id="0x7f6352b80eb0">
    <status>
      <basic>open</basic>
    </status>
  </tuple>
</presence>


U 2012/01/18 21:52:40.733052 127.0.0.1:5060 -> 127.0.0.1:57982
SIP/2.0 200 OK.
Via: SIP/2.0/UDP 127.0.1.1:5080;branch=z9hG4bK.29f7bb6d;rport=57982;alias;received=127.0.0.1.
From: sip:test at 127.0.0.1;tag=41f6277b.
To: sip:test at 127.0.0.1;tag=b27e1a1d33761e85846fc98f5f3a7e58.12b3.
Call-ID: 1106651003 at 127.0.1.1<mailto:1106651003 at 127.0.1.1>.
CSeq: 1 REGISTER.
Contact: <sip:test at 127.0.1.1:5080><sip:test at 127.0.1.1:5080>;expires=70.
Server: kamailio (3.3.0-dev5 (x86_64/linux)).
Content-Length: 0.
.


U 2012/01/18 21:52:40.740026 127.0.0.1:5060 -> 127.0.0.1:5060
SIP/2.0 200 OK.
Via: SIP/2.0/UDP 127.0.0.1;branch=z9hG4bK25a7.88a7c0d5.0.
To: sip:test at 127.0.0.1;tag=a6a1c5f60faecf035a1ae5b6e96e979a-0f93.
From: sip:test at 127.0.0.1;tag=533cb9e91f4b999cf76861cbb9ed54ed-76e3.
CSeq: 10 PUBLISH.
Call-ID: 53162b3d3a4cff50-20164 at 127.0.0.1<mailto:53162b3d3a4cff50-20164 at 127.0.0.1>.
Expires: 71.
SIP-ETag: a.1326919182.20164.3.0.
Server: kamailio (3.3.0-dev5 (x86_64/linux)).
Content-Length: 0.
.




U 2012/01/18 21:53:01.800384 127.0.0.1:36942 -> 127.0.0.1:5060
REGISTER sip:127.0.0.1 SIP/2.0.
Via: SIP/2.0/UDP 127.0.1.1:5080;branch=z9hG4bK.55f81f68;rport;alias.
From: sip:test at 127.0.0.1;tag=2f3b5433.
To: sip:test at 127.0.0.1.
Call-ID: 792417331 at 127.0.1.1<mailto:792417331 at 127.0.1.1>.
CSeq: 1 REGISTER.
Content-Length: 0.
Max-Forwards: 70.
User-Agent: sipsak 0.9.6.
Expires: 0.
Contact: sip:test at 127.0.1.1:5080.
.


U 2012/01/18 21:53:01.802227 127.0.0.1:5060 -> 127.0.0.1:5060
PUBLISH sip:test at 127.0.0.1 SIP/2.0.
Via: SIP/2.0/UDP 127.0.0.1;branch=z9hG4bK2bad.75340815.0.
To: sip:test at 127.0.0.1.
From: sip:test at 127.0.0.1;tag=533cb9e91f4b999cf76861cbb9ed54ed-e8e8.
CSeq: 10 PUBLISH.
Call-ID: 53162b3d3a4cff51-20163 at 127.0.0.1<mailto:53162b3d3a4cff51-20163 at 127.0.0.1>.
Content-Length: 0.
User-Agent: kamailio (3.3.0-dev5 (x86_64/linux)).
Max-Forwards: 70.
Event: presence.
Expires: 0.
SIP-If-Match: a.1326919182.20164.3.0.
.


U 2012/01/18 21:53:01.802366 127.0.0.1:5060 -> 127.0.0.1:36942
SIP/2.0 200 OK.
Via: SIP/2.0/UDP 127.0.1.1:5080;branch=z9hG4bK.55f81f68;rport=36942;alias;received=127.0.0.1.
From: sip:test at 127.0.0.1;tag=2f3b5433.
To: sip:test at 127.0.0.1;tag=b27e1a1d33761e85846fc98f5f3a7e58.a177.
Call-ID: 792417331 at 127.0.1.1<mailto:792417331 at 127.0.1.1>.
CSeq: 1 REGISTER.
Server: kamailio (3.3.0-dev5 (x86_64/linux)).
Content-Length: 0.
.


U 2012/01/18 21:53:01.806937 127.0.0.1:5060 -> 127.0.0.1:5060
SIP/2.0 200 OK.
Via: SIP/2.0/UDP 127.0.0.1;branch=z9hG4bK2bad.75340815.0.
To: sip:test at 127.0.0.1;tag=a6a1c5f60faecf035a1ae5b6e96e979a-2698.
From: sip:test at 127.0.0.1;tag=533cb9e91f4b999cf76861cbb9ed54ed-e8e8.
CSeq: 10 PUBLISH.
Call-ID: 53162b3d3a4cff51-20163 at 127.0.0.1<mailto:53162b3d3a4cff51-20163 at 127.0.0.1>.
Expires: 0.
SIP-ETag: a.1326919182.20164.3.0.
Server: kamailio (3.3.0-dev5 (x86_64/linux)).
Content-Length: 0.
.
Truphone Limited is a limited liability company registered in England & Wales, registered office: 5 New Street Square, London EC4A 3TW. Registered No. 04187081. VAT No. GB 851 5278 19.
Tru is a brand name of Truphone and is a Truphone Communications Service. Truphone is a trading name for a number of distinct legal entities that operate in combination. www.truphone.com<http://www.truphone.com>.

This e-mail, and any attachment(s), may contain information which is confidential and/or privileged, and is intended for the addressee only. If you are not the intended recipient, you may not use, disclose, copy or distribute this information in any manner whatsoever. If you have received this e-mail in error, please contact the sender immediately and delete it.




_______________________________________________

SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list

sr-users at lists.sip-router.org<mailto:sr-users at lists.sip-router.org>

http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



--

Daniel-Constantin Mierla -- http://www.asipto.com

http://linkedin.com/in/miconda -- http://twitter.com/miconda
Truphone Limited is a limited liability company registered in England & Wales, registered office: 5 New Street Square, London EC4A 3TW. Registered No. 04187081. VAT No. GB 851 5278 19.
Tru is a brand name of Truphone and is a Truphone Communications Service. Truphone is a trading name for a number of distinct legal entities that operate in combination. www.truphone.com<http://www.truphone.com>.

This e-mail, and any attachment(s), may contain information which is confidential and/or privileged, and is intended for the addressee only. If you are not the intended recipient, you may not use, disclose, copy or distribute this information in any manner whatsoever. If you have received this e-mail in error, please contact the sender immediately and delete it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20120119/71584b5d/attachment-0001.htm>


More information about the sr-users mailing list