Embedded IoT Protocols: WebSocket's Benefits and Drawbacks
by Exosite, on May 10, 2016
When choosing the right embedded protocol for an IoT solution, it is important to weigh all of the options, even those less apparent. In past blog segments of our Embedded IoT Protocols white paper, we have detailed the benefits and drawbacks of several popular embedded protocols commonly used in IoT solutions. In this week's IoT protocols post, we will be covering 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 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 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 deployments 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 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, unfortunately, 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.
For a complete description of all the embedded protocols, download the full Embedded IoT Protocols white paper and contact us for insight into your IoT project today.