WebRTC and SIP Over WebSockets

From reSIProcate
Revision as of 13:06, 19 December 2013 by Dpocock (talk | contribs)
Jump to navigation Jump to search


WebSockets is a mechanism for creating sockets from a web browser (typically running Javascript) to a server.

draft-ietf-sipcore-sip-websocket defines a way to use WebSockets formally as a transport for SIP. It is not possible to simply view the WebSocket as a tunnel and pass SIP messages through them. Specfically, SIP user agents and proxies must behave slightly differently when WebSockets is used instead of UDP or TCP, and the draft specifies what this means in practice. Code for implementing this protocol was developed on a branch and has subsequently been merged into the trunk for eventual release in reSIProcate 1.9.

WebRTC is related to WebSockets, but it is not the same thing. WebRTC specifies a way for a browser to act as an RTC endpoint, but not specifically as a SIP endpoint. There are SIP implementations written in Javascript that use the WebSocket transport to create WebRTC sessions, and a correctly adapted repro proxy server should be able to interact with such clients.

NAT busting: living the dream

  • NAT has always been a pain for SIP
  • WebRTC offers great hope for NAT busting, by masquerading as HTTP and HTTPS traffic and getting relayed by HTTP proxies
  • running a SIP proxy WebSocket server on port 443 makes it look like a real HTTPS server and allows end users to reach it from almost anywhere
    • the reSIProcate SIP proxy, repro, can listen on port 443 and talk WebSockets over TLS
  • for media relay to traverse NAT, it is also necessary to use a TURN server on port 443
    • the reSIProcate TURN server, reTurn, can listen on port 443
  • Unresolved issues:
    • it is also necessary for the TURN client to use secure TURN (TURNS) over port 443. This is not yet implemented in Google Chrome - bug tracker link

reSIProcate and WebRTC

  • WebRTC specifies that ICE/STUN/TURN support is mandatory in user agents/end-points. The reTurn server project and the reTurn client libraries from reSIProcate can fulfil this requirement.
  • WebRTC requires some mechanism for finding peers and initiating calls. SIP over WebSockets, interacting with a repro proxy server can fulfill this task.

Current support for WebSockets

Outstanding issues for a stable release

  • audit the security and resilience of parser code (e.g. against DoS attacks), as it is likely to be exposed to the hostile environment of the public internet
  • WS parser must reject frames with unknown extensions (currently they are just logged)
  • compatibility tests
    • make a list of products to test against
  • unit tests
    • develop some unit tests for the new WS code
  • check hardcoded df7jal23ls0d.invalid
  • ifdef USE_SSL for WS code
  • checking the type of frame
    • handling ping/pong frames?
  • keep alive mechanisms
    • SIP CRLF keep-alive over WS
  • frame and WS Message size checking
    • allocating larger buffer if necessary when receiving a big frame
    • sizing the WS Message unit buffer in advance to avoid resizing issues
    • must insert Content-Length header if relaying a message from WS to TLS, as WS does not mandate the client includes ContentLength
  • dealing with WS/WSS distinction in different contexts (e.g. no WSS in a SIP URI transport parameter, see email on list)
  • Nice to have (not mandatory for release)
    • support WS connections relayed from an Apache server
    • SIP over WebSocket client implementation
    • better implementation of the WS message unit abstraction
    • allowing the via received parameters to be suppressed (as per SIP over WS spec) to hide network topology

Related links

Javascript SIP clients for WebRTC capable browsers

WebRTC capable browsers

Other components

  • The SIP client must be hosted on a web server, any regular Apache instance is fine for this