<!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/4.6.1">
</HEAD>
<BODY>
OK.&nbsp; It looks like you have a bug in the client SIP over WebSocket stack.<BR>
<BR>
;transport=wss (as you have on the R-URI) is not correct.&nbsp; It should be ;transport=ws whether it is WS or WSS.&nbsp; The R-URI in the NOTIFY will be the contact that the client stack put into the SUBSCRIBE - so this wss is probably coming from the client stack.&nbsp; See draft-ietf-sipcore-sip-websocket section 5.2.2.<BR>
<BR>
The contents of the domain part of the R-URI here is also unusual - the draft recommends a made-up &quot;.invalid&quot; domain - again see draft-ietf-sipcore-sip-websocket section A.1.<BR>
<BR>
Also, this NOTIFY R-URI contains no ;alias= parameter - so unless you are using the latest git master and have enabled outbound you will probably have some routing problems with this.&nbsp; Basically, you should use the nathelper module and call add_contact_alias() for all dialog-forming and re-targetting requests (INVITE, NOTIFY, SUBSCRIBE, and UPDATE) that you receive from a WebSocket client.&nbsp; Then you should call handle_ruri_alias() for all requests that destined for a WebSocket client.<BR>
<BR>
Regards,<BR>
<BR>
Peter<BR>
<BR>
On Thu, 2013-01-24 at 15:46 +0000, Pete Kelly wrote:
<BLOCKQUOTE TYPE=CITE>
    This is the ruri:
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    NOTIFY sips:pete@10.15.20.113:55536;rtcweb-breaker=no;transport=wss SIP/2.0\r\n<BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    There is only one Via header:<BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    Via: SIP/2.0/TLS 10.15.20.170:443;branch=z9hG4bK8455.12ffc4c6.0\r\n<BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    And the Contact:
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    Contact: &lt;sip:10.15.20.170:443;transport=ws&gt;\r\n<BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    Contact looks suspicious as ws instead of wss?<BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    Does Kamailio use the usrloc info from the REGISTER to send out a NOTIFY?<BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    On 24 January 2013 15:34, Peter Dunkley &lt;<A HREF="mailto:peter.dunkley@crocodile-rcs.com">peter.dunkley@crocodile-rcs.com</A>&gt; wrote:
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BLOCKQUOTE>
        OK.&nbsp; This sounds like the NOTIFY is not being routed through the WebSocket module then.&nbsp; Instead it is coming out as a raw SIP message.<BR>
        <BR>
        This would explain a lot.&nbsp; This could well be caused by the routing within Kamailio not being quite right.&nbsp; For example, if the ;transport=ws parameter is missing from some Route/Record-Route/Contact/Request -URI you could see something like this.<BR>
        <BR>
        It could be a code problem or just a problem with the configuration file that is causing this.&nbsp; I suspect it may also be related to the use of the nathelper stuff and the contact aliasing that needs to be used with WebSocket (unless you are using the latest code and have configured outbound).<BR>
        <BR>
        Regards,<BR>
        <BR>
        Peter
    </BLOCKQUOTE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BLOCKQUOTE>
        <BR>
        <BR>
        On Thu, 2013-01-24 at 15:29 +0000, Pete Kelly wrote: <BR>
        <BLOCKQUOTE TYPE=CITE>
            Hi Peter, thanks for that info.<BR>
            <BR>
            It looks like all the packets marked Websocket in Wireshark are coming across OK from Kamailio. The first nibble is always 1000 as expected.<BR>
            <BR>
            <BR>
            However I notice now that whenever a NOTIFY is sent out from Kamailio the packet is *not* a Websocket packet, it's identified as HTTP within Wireshark and does not contain the 4 &quot;header&quot; bytes that Websocket packets seem to contain.<BR>
            <BR>
            <BR>
            As a result the first byte for the NOTIFY is the letter 'N' represented as 01001110.<BR>
            <BR>
            <BR>
            So the browser could be reading the second bit as 1, and interpreting that as meaning the compressed bit set to 1.<BR>
            <BR>
            <BR>
            Does that sound plausible?<BR>
            <BR>
            <BR>
            On 24 January 2013 14:54, Peter Dunkley &lt;<A HREF="mailto:peter.dunkley@crocodile-rcs.com">peter.dunkley@crocodile-rcs.com</A>&gt; wrote:<BR>
            <BLOCKQUOTE>
                The RSV1 bit (which is the compressed bit) should be the second bit from the left in the WebSocket frame. &nbsp;The first bit is the FIN (should always be one here), then you have RSV1, RSV2, and RSV3, and the last nibble of the first byte will be the opcode. <BR>
                <BR>
                <BR>
                Regards, <BR>
                <BR>
                <BR>
                Peter <BR>
                <BR>
                <BR>
                On 24 Jan 2013, at 14:47, Pete Kelly &lt;<A HREF="mailto:pkelly@gmail.com">pkelly@gmail.com</A>&gt; wrote:<BR>
                <BR>
                <BR>
                <BLOCKQUOTE TYPE=CITE>
                    Chrome 26, 24 and Firefox nightly all exhibit the same behaviour. <BR>
                    <BR>
                    <BR>
                    I've decrypted the packets in wireshark, could you point me at what I am looking for to see the compressed bit? <BR>
                    <BR>
                    <BR>
                    Wireshark reports (on what seems to be the problematic frame) &quot;This frame ACKs a segment we have not seen&quot; <BR>
                    <BR>
                    <BR>
                    On 24 January 2013 13:50, Peter Dunkley &lt;<A HREF="mailto:peter.dunkley@crocodile-rcs.com">peter.dunkley@crocodile-rcs.com</A>&gt; wrote: <BR>
                    <BLOCKQUOTE>
                        Have you checked to see if there are any known bugs in the browser you are using?<BR>
                        <BR>
                        As the WebSocket message compression stuff is still draft the browser implementation probably won't be complete or fully tested yet.<BR>
                        <BR>
                        As I said, the Kamailio WebSocket implementation does not support any extensions and all the reserved bits are 0'd.&nbsp; So I don't think it is likely that the compressed bit is set to 1 at all.<BR>
                        <BR>
                        The only other thing I can suggest is capturing your TLS traffic with WireShark and importing the certificates into it so you can decode the packets.&nbsp; At that point you should be able to look at the binary of the frame and see if the compressed bit is set or not.<BR>
                        <BR>
                        Regards,<BR>
                        <BR>
                        Peter <BR>
                        <BR>
                        <BR>
                        On Thu, 2013-01-24 at 13:45 +0000, Pete Kelly wrote: <BR>
                        <BLOCKQUOTE TYPE=CITE>
                            Hi Peter<BR>
                            <BR>
                            <BR>
                            I can confirm it works correctly for WS and not WSS, and it appears to be only the NOTIFY request in the direction of Kamailio &gt; UAC. INVITE requests in the direction of Kamailio &gt; UAC are fine.<BR>
                            <BR>
                            <BR>
                            I've tried it with the tls&nbsp;tls_disable_compression flag set to both 0 and 1<BR>
                            <BR>
                            <BR>
                            Pete<BR>
                            <BR>
                            <BR>
                            On 24 January 2013 09:53, Peter Dunkley &lt;<A HREF="mailto:peter.dunkley@crocodile-rcs.com">peter.dunkley@crocodile-rcs.com</A>&gt; wrote:<BR>
                            <BLOCKQUOTE>
                                Hi,<BR>
                                <BR>
                                I've done some checking online and in the code.&nbsp; The compressed bit is defined in draft-ietf-hybi-permessage-compression and uses the RSV1 bit from the WebSocket frame header.&nbsp; As per RFC 6455 the Kamailio WebSocket implementation is careful to leave RSV1, RSV2, and RSV3 with values of 0.<BR>
                                <BR>
                                As this part of the code is identical for WS and WSS connections can you confirm that it works correctly for WS?<BR>
                                <BR>
                                Regards,<BR>
                                <BR>
                                Peter <BR>
                                <BR>
                                <BR>
                                On Thu, 2013-01-24 at 09:09 +0000, Peter Dunkley wrote: <BR>
                                <BLOCKQUOTE TYPE=CITE>
                                    I shod also add that the Kamailio WebSocket implementation does not support any extensions. &nbsp;So unless the deflate frame extension is implicit for TLS it will not be negotiated. &nbsp;Further, the implementation does not set any compressed bits and all unused flags etc should be zeroed automatically - but I will look at the code later.<BR>
                                    <BR>
                                    <BR>
                                    Peter<BR>
                                    <BR>
                                    On 24 Jan 2013, at 09:05, Peter Dunkley &lt;<A HREF="mailto:peter.dunkley@crocodile-rcs.com">peter.dunkley@crocodile-rcs.com</A>&gt; wrote:<BR>
                                    <BR>
                                    <BR>
                                    <BLOCKQUOTE TYPE=CITE>
                                        I am not sure how to investigate this. &nbsp;It sounds like it might be a TLS related problem (or a WebSocket/TLS interworking problem in Kamailio). &nbsp;I don't know anything about the Kamailio TLS implementation - I just drop WebSocket frames into it as required. <BR>
                                        <BR>
                                        <BR>
                                        I did do (a little) WSS testing and saw no problems myself. <BR>
                                        <BR>
                                        <BR>
                                        Regards, <BR>
                                        <BR>
                                        <BR>
                                        Peter<BR>
                                        <BR>
                                        On 23 Jan 2013, at 22:12, Pete Kelly &lt;<A HREF="mailto:pkelly@gmail.com">pkelly@gmail.com</A>&gt; wrote:<BR>
                                        <BR>
                                        <BR>
                                        <BLOCKQUOTE TYPE=CITE>
                                            Hi, I am having an issue at the moment with SIP NOTIFY messages being sent from Kamailio (latest git master) over wss transport<BR>
                                            <BR>
                                            I am getting reports from the receiving end saying &quot;Compressed bit must be 0 if no negotiated deflate-frame extension&quot;<BR>
                                            <BR>
                                            The only reference I can find to it is at the following URL... where the problem was caused by the server miscalculating the size of the msg:&nbsp;<A HREF="http://stackoverflow.com/questions/12308728/compressed-bit-must-be-0-when-sending-a-message-to-websocket-client">http://stackoverflow.com/questions/12308728/compressed-bit-must-be-0-when-sending-a-message-to-websocket-client</A><BR>
                                            <BR>
                                            Does anyone have any suggestions as to how I could debug this within Kamailio? It sounds like Kamailio may be sending some incorrect packet information but I am unsure at this point.<BR>
                                            <BR>
                                            <BR>
                                            <BR>
                                            _______________________________________________<BR>
                                            SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<BR>
                                            <A HREF="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</A><BR>
                                            <A HREF="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</A><BR>
                                            <BR>
                                        </BLOCKQUOTE>
                                        _______________________________________________<BR>
                                        SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<BR>
                                        <A HREF="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</A><BR>
                                        <A HREF="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</A><BR>
                                        <BR>
                                    </BLOCKQUOTE>
<PRE>
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<A HREF="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</A>
<A HREF="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</A>
</PRE>
                                </BLOCKQUOTE>
                                <BR>
                                <BR>
                                <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<PRE>
-- 
Peter Dunkley
Technical Director
Crocodile RCS Ltd
</PRE>
</TD>
</TR>
</TABLE>
                            </BLOCKQUOTE>
                            <BR>
                            <BR>
                        </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>
                    <BR>
                </BLOCKQUOTE>
            </BLOCKQUOTE>
            <BR>
            <BR>
        </BLOCKQUOTE>
        <BR>
        <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<PRE>
-- 
Peter Dunkley
Technical Director
Crocodile RCS Ltd
</PRE>
</TD>
</TR>
</TABLE>
    </BLOCKQUOTE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
    <BR>
    <BR>
</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>