[sr-dev] WebSocket (RFC 6455) and draft-ibc-sipcore-sip-websocket on Kamailio

Peter Dunkley peter.dunkley at crocodile-rcs.com
Mon Jun 18 12:09:58 CEST 2012


Hi Klaus,

Thanks but it doesn't do what I need.  That function closes the
connection after the next send by setting SND_F_CON_CLOSE (which is the
what the tcpconn_close_after_send() macro in tcp_conn.h does too).

Unfortunately, I need to be able to cleanly close a connection
immediately without any further sends.

Thanks,

Peter

On Mon, 2012-06-18 at 12:01 +0200, Klaus Darilion wrote:

> See how this function works:
> 
> http://www.kamailio.org/dokuwiki/doku.php/core-cookbook:3.1.x#set_forward_close
> 
> It might help you
> 
> On 17.06.2012 15:11, Peter Dunkley wrote:
> > Hi,
> >
> > One of the things I need to be able to do from the WebSocket module is to
> > cleanly close TCP/TLS connections when I receive/send a Close() frame.
> >
> > Is there an easy way to do this from a Kamailio module?
> >
> > Regards,
> >
> > Peter
> >
> >> Hello,
> >>
> >> On 6/15/12 11:33 AM, Peter Dunkley wrote:
> >>> Hi Daniel,
> >>>
> >>> Thanks for the encouragement.
> >>>
> >>> I could do with a guide here.  I think there is only a few hours work
> >>> left to finish off the handshake and basic module stuff. After that I
> >>> think the next step needs to be:
> >>> - Getting the module to register with core to receive WS frames (which
> >>> may arrive over TCP or TLS)
> >>> - Giving the module/core the ability to "change" the connection the
> >>> handshake came in on from SIP/HTTP to WS (so that new messages go
> >>> straight to the handler in the new module)
> >>> - In the module adding handling for Close, Ping, and Pong
> >>> - To do the handling for Ping the module needs to be able to send WS
> >>> frames out (over TCP or TLS)
> >>> - In the module "printing" received binary and text frames (which will
> >>> contain SIP requests)
> >>>
> >>> The bits I need help with here the most are the registering the module
> >>> to receive the WS frames and sending WS frames (over TCP or TLS), and
> >>> adding the ability for the module/core to "upgrade" the connection
> >>> from SIP/HTTP to WS after successful handshake.
> >>
> >> I think of doing it like:
> >> - when WS handshake is completed, mark the tcp connection as being WS
> >> from the module (a new flag or so)
> >> - then in the TCP read function (iirc, tcp_read.{c,h} in core) if the
> >> connection is marked WS, then execute a callback that is registered by
> >> the module
> >> - this is pretty much how http and msrp work, but there the detection is
> >> on the content, not on the socket type. HTTP is using so called no-SIP
> >> content callback, while MSRP is using a dedicated core event
> >>
> >> For sending, using tcp_send(...) (looking at msrp module will give the
> >> right directions) should do it -- the function takes the tcp connection
> >> as parameter as well as the outgoing buffer and encrypts the content if
> >> actually is over TLS. The send operation may become transparent as soon
> >> as the algorithm for finding the connection can grep on WS/WSS protocol.
> >>
> >> Cheers,
> >> Daniel
> >>
> >>>
> >> --
> >> Daniel-Constantin Mierla - http://www.asipto.com
> >> http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
> >> Kamailio Advanced Training, Seattle, USA, Sep 23-26, 2012 -
> >> http://asipto.com/u/katu
> >> Kamailio Practical Workshop, Netherlands, Sep 10-12, 2012 -
> >> http://asipto.com/u/kpw
> >>
> >>
> >
> >


-- 
Peter Dunkley
Technical Director
Crocodile RCS Ltd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20120618/1dbeb43c/attachment.htm>


More information about the sr-dev mailing list