WebSocket

WebSocket is a standard protocol that enables a web browser or client application and a web server application to communicate by using one full duplex connection.

Open Liberty For the most recent information about Developing WebSocket applications in Liberty, see the Open Liberty website.

HTTP was not designed for long-lived, real-time, full duplex communication between two applications. In many instances, a user's web server application or servlet wants to communicate with a client browser or application in a long-lived, real-time, full duplex conversation. In other words, the two applications want to freely read and write data back and forth. An example of this type of application is one that constantly displays changing currency exchange rates on the web browser of a stock trader. Current solutions that involve existing HTTP technology to accomplish this type of communication are cumbersome and inefficient. HTTP solutions, for constant two-way communication between a browser and a server, mostly consists of either polling or two open HTTP connections that handle one-way traffic only, or both.

WebSocket uses a standard HTTP request-response sequence to establish a connection. When the connection is established, the WebSocket API provides a read and write interface for reading and writing data over the established connection in an asynchronous full duplex manner. WebSocket also provides an interface for asynchronously closing the connection from either side.

Because WebSocket uses a standard HTTP request-response sequence to establish a connection, the connection initiation connects though firewalls and proxies in the same manner as an HTTP connection. WebSocket requires full duplex communication, including simultaneous reads and writes on the same connection. The WebSphere web server plug-in supports full duplex communication, but other firewalls and proxies might require modification to enable this support. WebSocket can also use SSL for secure connections and transmission of data. This protocol uses SSL in the same way that the HTTP protocol uses SSL.

The Liberty WebSocket feature implements the following specifications:

Liberty supports the WebSocket 1.0 and WebSocket 1.1 specifications. Compared to WebSocket 1.0, WebSocket 1.1 supports a more robust way of specifying message handlers.