[SR-Users] SIP over WebSockets error: bad request

Peter Dunkley peter.dunkley at crocodile-rcs.com
Tue Mar 26 22:29:24 CET 2013


tcp_accept_no_cl=yes should always be used when Kamailio is receiving HTTP
traffic (the event_route[xhttp:request] is used) as HTTP/1.1 does not use
the Content-Length: header if there is no message body (as in the case of
the WebSocket handshake).  Even when there is a body Content-Length: is
not needed if HTTP/1.0 backwards compatibility is not required.

SIP is different.  A SIP message over TCP must always contain a
Content-Length: header.  When there is no body the Content-Length: is 0.

JsSIP is doing exactly the right thing here.  It should not be putting
Content-Length: into that WebSocket handshake.

Regards,

Peter

> Hello Peter,
>
> Thank you for the quick reply.  Yes, that did the trick.  Changing
> "tcp_accept_no_cl" to value of no was the resolution.
>
> It seems that the JsSIP Tryit sample code, which I was trying to hack,
> doesn't use Content-Length in the header.  I wonder if this should be
> changed to set the Content-Length in the HTTP header.
>
> At any rate, thanks again.  I'm now registered, which is what I was
> looking
> to do.
>
> Brad
>
>
> On Tue, Mar 26, 2013 at 4:08 PM, Peter Dunkley <
> peter.dunkley at crocodile-rcs.com> wrote:
>
>> Hello,
>>
>> Check that you have "tcp_accept_no_cl=yes" in your configuration.
>>
>> This is required for Kamailio to parse messages over TCP which do not
>> have
>> "Content-Length:" headers (including HTTP requests).
>>
>> If that doesn't work try running Kamailio with debug output at its
>> highest
>> level (you'll need to output debug to stderr when doing this as syslog
>> won't capture it all) so that more detailed debug can be provided to
>> track
>> this down.
>>
>> Regards,
>>
>> Peter
>>
>> > Hi,
>> >
>> > Wondering if anyone could please help me debug what is wrong with my
>> > kamailio.cfg for Websockets support.  I'm using JsSIP sample
>> application,
>> > and I've compiled Kamailio 4.0 for WS support.  My config is borrowed
>> from
>> > link this link [1].  Wondering if anyone can help me debug this.
>> Error
>> is
>> > bad request, from syslog:
>> >
>> > Mar 26 19:26:42 ace /usr/local/sbin/kamailio[25774]: ERROR: <core>
>> > [tcp_read.c:1296]: ERROR: tcp_read_req: bad request, state=7, error=4
>> > buf:#012GET / HTTP/1.1#015#012Upgrade: websocket#015#012Connection:
>> > Upgrade#015#012Host: sip.XXX.net:8888#015#012Origin:
>> > http://sip.XXX.net#015#012Sec-WebSocket-Protocol: sip#015#012Pragma:
>> > no-cache#015#012Cache-Control: no-cache#015#012Sec-WebSocket-Key:
>> > p2cM0XbAejvloY1h+pACIw==#015#012Sec-WebSocket-Version:
>> > 13#015#012Sec-WebSocket-Extensions:
>> x-webkit-deflate-frame#015#012Cookie:
>> > _pk_id.6.4c1d=3ee006d4f8af735c.1363914085.2.1364326003.1363915087.;
>> > _pk_ses.6.4c1d=*#015#012#015#012#012parsed:#012GET /
>> > HTTP/1.1#015#012Upgrade: websocket#015#012Connection:
>> Upgrade#015#012Host:
>> > sip.XXX.net:8888#015#012Origin:
>> > http://sip.XXX.net#015#012Sec-WebSocket-Protocol: sip#015#012Pragma:
>> > no-cache#015#012Cache-Control: no-cache#015#012Sec-WebSocket-Key:
>> > p2cM0XbAejvloY1h+pACIw==#015#012Sec-WebSocket-Version:
>> > 13#015#012Sec-WebSocket-Extensions:
>> x-webkit-deflate-frame#015#012Cookie:
>> > _pk_id.6.4c1d=3ee006d4f8af735c.1363914085.2.1364326003.1363915087.;
>> > _pk_ses.6.4c1d=*#015#012#015#012
>> >
>> > Any ideas?  Can send my kamailio.cfg if necessary.
>> >
>> >
>> > [1]  Kamailio sample config for WebSockets
>> > https://gist.github.com/jesusprubio/4066845
>> > _______________________________________________
>> > SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing
>> list
>> > sr-users at lists.sip-router.org
>> > http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>> >
>>
>>
>> --
>> Peter Dunkley
>> Technical Director
>> Crocodile RCS Ltd
>>
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users at lists.sip-router.org
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>


-- 
Peter Dunkley
Technical Director
Crocodile RCS Ltd




More information about the sr-users mailing list