Exosite

May 10, 2016

Embedded IoT Protocols: WebSocket's Benefits and Drawbacks

By Exosite · 1 min read · From the team

When choosing the right embedded protocol for an IoT solution, it is important to weigh all of the options, even those less apparent. This post covers WebSocket, an unsuspected addition to the list.

WebSocket is not a protocol that was designed for use in IoT product deployments but instead, as the name suggests, for use with the web. It lets web browsers and web servers communicate continuously using a message-based, bi-directional channel.

The Benefits

The biggest benefit of using the WebSocket protocol is its network compatibility. A WebSocket connection is established first as an HTTP request, so if a network can support an HTTP request, it can almost certainly support WebSocket. The server-side library support is also a major benefit to the WebSocket protocol, making implementation on a server much easier thanks to the wide deployment of existing WebSocket servers for the web. Like HTTP, WebSocket uses TCP and, thus, can use TLS and take advantage of its wider availability in existing network stacks.

The Downside

The biggest downside to using WebSocket is the weight of the protocol and the hardware requirements that it brings with it. WebSocket requires a TCP implementation, which may or may not be a problem, but it also requires an HTTP implementation for the initial connection setup. Additionally, WebSocket was not designed with the requirements of highly constrained embedded systems in mind, so implementations may not be straightforward, and there are currently no useful, open source WebSocket implementations targeted at embedded systems. Again, as it was with HTTP, these problems may not be impossible to overcome. The decision to use the WebSocket protocol will depend heavily on outside factors, and those factors may make WebSocket an attractive option.