Our client for this project needed a more reliable connection between their IoT device and their cloud app server than their WiFi based IoT platform could provide. In certain mission critical deployments, they needed a rock-solid way to send "events" (short JSON objects) that, barring cloud server downtime or loss of power at the device, was both low latency and tolerant to internet outages and packet loss.
To address these requirements, we developed an "IoT Relay" to deliver
events from the IoT device to the cloud server entirely through wired
connections. A client side relay receives events over USB from the
IoT device, then forwards them over ethernet LAN/WAN to a server
side relay that is co-located with the cloud app server. The
server side relay then forwards the events to a customizable "webhook" URL
on the cloud app server. The relay server also forwards events to any
connected real-time "event monitor" clients. To minimize latency, we chose the
WebSocket Protocol
to handle persistent connections to the relay server. Extensive buffering and
error handling in the client side relay ensure events are delivered
reliably in case of dropped websocket connections.
The system was exhaustively tested and after some difficult bugs were fixed, deployed in production on AWS. Several mission critical deployments - live athletic competitions - have completed successfully with dozens of IoT devices generating 10K+ events in the span of a few days with 0% loss.