<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.32.2">
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#ffffff">
Thanks Daniel,<BR>
<BR>
I have tested this change and it is working in my environment.<BR>
<BR>
Peter<BR>
<BR>
On Thu, 2011-04-07 at 12:00 +0200, Daniel-Constantin Mierla wrote:<BR>
<BLOCKQUOTE TYPE=CITE>
    Hi Peter,<BR>
    <BR>
    On 4/7/11 11:42 AM, Peter Dunkley wrote: <BR>
    <BLOCKQUOTE TYPE=CITE>
        Hi Daniel,<BR>
        <BR>
        This SUBSCRIBE is a back-end SUBSCRIBE generated by RLS and directed to PRESENCE.<BR>
        <BR>
        The RLS module sends that SUBSCRIBE and gets a 202 back from PRESENCE.&nbsp; The PRESENCE module is then sending that NOTIFY back to the RLS module after the unSUBSCRIBE is complete.<BR>
    </BLOCKQUOTE>
    ok, now I have the proper message flow.<BR>
    <BR>
    <BLOCKQUOTE TYPE=CITE>
        So:<BR>
        - Either the PRESENCE module should not send this NOTIFY to the RLS after the unSUBSCRIBE, or<BR>
        - The RLS module should be prepared to receive a NOTIFY from PRESENCE after the unSUBSCRIBE<BR>
    </BLOCKQUOTE>
    <BR>
    Perhaps the best will be to have delayed delete of un-SUBSCRIBEd dialogs. The quick solution is to reply 200ok for NOTIFY requests with state terminated. I will make a patch for the later.<BR>
    <BR>
    Thanks,<BR>
    Daniel<BR>
    <BR>
    <BLOCKQUOTE TYPE=CITE>
        <BR>
        Thanks,<BR>
        <BR>
        Peter<BR>
        <BR>
        On Thu, 2011-04-07 at 11:34 +0200, Daniel-Constantin Mierla wrote:<BR>
        <BLOCKQUOTE TYPE=CITE>
            Hi Peter,<BR>
            <BR>
            On 4/4/11 3:39 PM, Peter Dunkley wrote: <BR>
            <BLOCKQUOTE TYPE=CITE>
                Hello Daniel,<BR>
                <BR>
                I have looked into the new error message.&nbsp; I now get:<BR>
                <BR>
                &nbsp;&nbsp;&nbsp; 7(21352) ERROR: rls [resource_notify.c:250]: record not found<BR>
                <BR>
                This looks very similar to the previous issue.&nbsp; What appears to be happening is that the RLS is successfully un-subscribing from the presence module with a SUBSCRIBE that looks like:<BR>
                <BR>
                <BLOCKQUOTE>
                    SUBSCRIBE <A HREF="sip:alice@crocodile-rcs.com">sip:alice@crocodile-rcs.com</A> SIP/2.0<BR>
                    Via: SIP/2.0/UDP 46.38.172.248;branch=z9hG4bKf89b.b9ec2180000000000000000000000000.0<BR>
                    To: <A HREF="sip:alice@crocodile-rcs.com.">sip:alice@crocodile-rcs.com</A><BR>
                    From: <A HREF="sip:bob@crocodile-rcs.com">sip:bob@crocodile-rcs.com</A>;tag=533cb9e91f4b999cf76861cbb9ed54ed-8c1c<BR>
                    CSeq: 10 SUBSCRIBE<BR>
                    Call-ID: <A HREF="mailto:6c60e3f8-21440@127.0.0.1.">6c60e3f8-21440@127.0.0.1</A><BR>
                    Content-Length: 0<BR>
                    User-Agent: Crocodile SuperNode 1.1<BR>
                    Max-Forwards: 70<BR>
                    Event: presence<BR>
                    Contact: &lt;<A HREF="sip:rls@46.38.172.248:5060">sip:rls@46.38.172.248:5060</A>&gt;<BR>
                    Expires: 0<BR>
                    Supported: eventlist<BR>
                    Accept: application/pidf+xml, application/rlmi+xml, application/watcherinfo+xml, multipart/related<BR>
                </BLOCKQUOTE>
                <BR>
                After accepting (with 202) this SUBSCRIBE the presence module tries to send a NOTIFY back to the RLS module:<BR>
                <BR>
                <BLOCKQUOTE>
                    NOTIFY <A HREF="sip:rls@46.38.172.248:5060">sip:rls@46.38.172.248:5060</A> SIP/2.0<BR>
                    Via: SIP/2.0/UDP 127.0.0.1;branch=z9hG4bK7a28.7240a060000000000000000000000000.0<BR>
                    To: <A HREF="sip:bob@crocodile-rcs.com">sip:bob@crocodile-rcs.com</A>;tag=533cb9e91f4b999cf76861cbb9ed54ed-8c1c<BR>
                    From: <A HREF="sip:alice@crocodile-rcs.com">sip:alice@crocodile-rcs.com</A>;tag=a6a1c5f60faecf035a1ae5b6e96e979a-5cd7<BR>
                    CSeq: 1 NOTIFY<BR>
                    Call-ID: <A HREF="mailto:6c60e3f8-21440@127.0.0.1.">6c60e3f8-21440@127.0.0.1</A><BR>
                    Content-Length: 0<BR>
                    User-Agent: Crocodile SuperNode 1.1<BR>
                    Max-Forwards: 70<BR>
                    Event: presence<BR>
                    Contact: &lt;<A HREF="sip:127.0.0.1:5060">sip:127.0.0.1:5060</A>;transport=udp&gt;<BR>
                    Subscription-State: terminated;reason=timeout<BR>
                </BLOCKQUOTE>
                This NOTIFY is passed into the RLS module using rls_handle_notify() and the error message from above appears in the log file.&nbsp; There is no final response sent to the NOTIFY so the error message appears repeatedly for 32 seconds until the presence module times out.<BR>
                <BR>
                I think there are two issues here: 
                <UL>
                    <LI>After completing the unSUBSCRIBE the RLS module removes the dialog from the hash table.&nbsp; This means that the NOTIFY from presence doesn't match a dialog - hence the error message. 
                </UL>
            </BLOCKQUOTE>
            is this SBSCRIBE request handled by RLS module, not by presence (ie, it is for a resource list or for an user)?<BR>
            <BR>
            <BLOCKQUOTE TYPE=CITE>
                <UL>
                    <LI>rls_handle_notify() does not send an Fxx (or at least does not in this case) when it receives a validly formed NOTIFY that still causes an error. 
                </UL>
                <BR>
                Can you suggest a work-around?<BR>
            </BLOCKQUOTE>
            rls_handle_notify() sends 200ok only when returning true to config. In this case, since it hasn't found the proper dialog, will return false.<BR>
            <BR>
            Try:<BR>
            <BR>
            if(!rls_handle_notify()) {<BR>
            &nbsp;&nbsp; send_reply(&quot;404&quot;, &quot;Not found&quot;);<BR>
            &nbsp; exit;<BR>
            }<BR>
            <BR>
            Perhaps will be nicer to differentiate between the cases of internal error, whether it is some server fault (e.g., out of memory, broken db connection) or the dialog is not found, to be able to send back either 500 or 404.<BR>
            <BR>
            Cheers,<BR>
            Daniel<BR>
            -- 
<PRE>
Daniel-Constantin Mierla
<A HREF="http://www.asipto.com">http://www.asipto.com</A>
</PRE>
        </BLOCKQUOTE>
        <BR>
        <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<PRE>
-- 
Peter Dunkley
Technical Director
Crocodile RCS Ltd
</PRE>
</TD>
</TR>
</TABLE>
    </BLOCKQUOTE>
    <BR>
<PRE>
-- 
Daniel-Constantin Mierla
<A HREF="http://www.asipto.com">http://www.asipto.com</A>
</PRE>
</BLOCKQUOTE>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<PRE>
-- 
Peter Dunkley
Technical Director
Crocodile RCS Ltd
</PRE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>