By Katherine Merrick, Principal Product Manager
Low-latency applications typically require a faster means of communication than what HTTP can deliver. Examples include multiplayer online gaming or chat applications where real-time, interactive communications are needed to provide the right user experience. WebSockets is a real-time communication protocol that enables an open, continuous, two-way connection between a client and a server. This enables data to be sent to a client (i.e., a browser), even without the client having to request it. With the HTTP protocol, the server only responds if the client sends a request.
Financial institutions are another use case for WebSockets. Recently, we worked with a major North American bank who is using the WebSocket protocol to establish an open connection for their origin server to send real-time notifications whenever trades go through without the client having to poll for them.
How does the WebSocket protocol work?
WebSocket connections start as regular HTTP connections. To establish a WebSocket connection, the client and server upgrade from the HTTP protocol to the WebSocket protocol during their initial handshake (this protocol switch is known as the WebSocket handshake).
To initiate this upgrade the client sends a request to the server using the following headers:
If the server understands the WebSocket protocol and agrees to the switch, it sends back a special response code: 101 (Switching protocols) with the same two headers. At that point, the HTTP connection is replaced by the WebSocket connection over the same underlying TCP/IP connection. Once established, WebSocket data frames can be sent back and forth between the client and the server in full-duplex mode until one side closes the connection.
The key benefits of WebSockets over HTTP include:
Verizon Media is pleased to offer support for the WebSocket protocol across our entire worldwide delivery network. As we move into the age of IoT and edge computing, the WebSocket protocol will be beneficial for companies wanting to offer low-latency applications at the edge.
To learn how to implement WebSockets for your application, fill out the form below or call us today.