Industrial Internet Application Development
上QQ阅读APP看书,第一时间看更新

WebSocket communication 

WebSocket cloud connectivity is another option to consider for IoT applications and solves some of the issues with MQTT. WebSockets is designed to be complementary to HTTP,  yet it is closer to TCP and lean—it only uses 2-6 bytes of headers for data transmission. WebSocket leverages the existing HTTP infrastructures such as servers, proxies, and security headers for authentications/authorizations. WebSocket is a bi-directional, full duplex, and low-level communication protocol that runs on top of TCP. A WebSocket starts off as a standard HTTP connection but then gets upgraded to a WebSocket connection to create a persistent TCP connection with the server using a single socket. WebSocket is part of the HTML5 standard. Many of the modern browsers support WebSocket protocols natively and web applications can use the JavaScript library to use WebSocket communications. WebSocket outshines HTTP in the development of real-time, event-driven, and low latency applications and will be a great fit for IoT use cases.

 Although WebSocket enables us to use the HTTP security infrastructure for the IoT devices, it does not eliminate interoperability issues since the messaging format is not defined by WebSockets, and it is up to the application to utilize standards such as JSON. WebSocket also requires a full web client to run on the device, which may not be possible in all situations due to device hardware footprints limitations. WebSocket is also less reliable than a messaging protocol such as MQTT and it is difficult to scale WebSockets servers as the load increases. Scaling WebSockets using a load balancer is a complex task.