What is WebSocket?

HTML5 WebSocket represents the first major upgrade in the history of web communications. Before WebSocket, all communication between web clients and servers relied only on HTTP. Now, dynamic data can flow freely over WebSocket connections that are persistent (always on), full duplex (simultaneously bi-directional) and blazingly fast.

The WebSocket standard enables entirely new kinds of applications, just as the Web itself originally did. Businesses can now leverage this new technology to tap novel sources of revenue, reduce time-to-market, and slash the costs and complexity of their IT infrastructure.

The main purpose of WebSocket is to provide full-duplex communications channels over a single TCP connection that can support any protocol. Both the WebSocket API itself (W3C) and the WebSocket protocol are standards, see RFC 6455. While WebSocket was designed originally to be implemented in both web browsers and web servers, it provides such significant architectural benefits that it is being used more and more to communicate between any client and server that has to connect over the internet, for example in between native mobile applications and servers, and in between devices.


Build a WebSocket-Powered Application Get Started

What WebSocket means for architects and developers

WebSocket itself is an independent TCP-based protocol, but it is designed to support any other protocol that would traditionally only run on top of a pure TCP connection. The best way to think of WebSocket is as a transport layer on top of which any other protocol can run. The WebSocket API supports the ability to define sub-protocols: protocol libraries that can interpret specific protocols. Examples of such protocols include XMPP, STOMP, and AMQP. In this way, developers no longer have to think in terms of the HTTP request-response paradigm, but instead, they can select the most appropriate protocol for the type of applications they are writing. The only requirement on the browser-side is to run a JavaScript library that can interpret the WebSocket handshake, establish and maintain a WebSocket connection, and interpret specific protocols coming down the wire. On the server side, the industry standard is to use existing protocol libraries that run on top of TCP and leverage a WebSocket Gateway such as any of the Kaazing WebSocket Gateways supporting protocols like XMPP and AMQP, to translate TCP traffic into corresponding WebSocket traffic in a way that is both scalable and secure.

WebSocket for architects and developers

WebSocket connections are initiated via HTTP: HTTP servers typically interpret WebSocket handshakes as an Upgrade request. As such, WebSocket can both be a complementary add-on to an existing HTTP environment and can provide the required infrastructure to add web functionality that relies on more advanced, full duplex protocols that allow data to flow in both directions between client and server. HTTP remains the protocol of choice for transferring static html content and, with the advent of HTML5, HTTP provides the means by which to transfer a rich HTML5 application to the browser that will subsequently use a WebSocket connection to leverage the protocol most suitable for that specific HTML5 application. More technical info on WebSocket

What WebSocket means for DevOps

The pressure to build applications that can communicate in real-time pre-dates the existence of WebSocket. Solutions, such as AJAX and COMET exist to run on top of HTTP and simulate real-time interactions. Unfortunately, these technologies use HTTP servers in a way that they were never designed to be used, causing a massive overhead in resources. Unlike traditional static web pages, dynamic web applications that leverage purely the HTTP protocol are incredibly costly to run. With WebSocket, the savings on server resources are enormous. There are many examples where real time applications based solely on http and requiring hundreds of servers to run suddenly drop to only two or three servers after they have been ported to WebSocket. For IT, this means significant cost savings that can be re-invested in building new features that bring new revenues. And since WebSocket is a standard, any application stack that leverages WebSocket in a standard way becomes a safe investment. An example of a standards-based server is the Kaazing WebSocket Gateway, an enterprise-grade, production server, built to help enterprises and their developers rapidly and easily build WebSocket solutions successfully and importantly, cost-effectively. Kaazing WebSocket Gateway offer additional security, emulation, pre-built API’s, client libraries and mobile features, it is built to improve the overall productivity for developers and system architects – shortening time and cost to market.