Node-RED communications protocols

Published: | Updated: | by Julian Knight Reading time ~1 min.
๐Ÿ“– Kb | ๐Ÿ“Ž Development | ๐Ÿ”– Node-RED, Communications, Protocols, MQTT, Websockets, TCP, UDP

Node-RED has an excellent choice of communications protocols available to it. This article looks at the main options and their strengths and weaknesses. It also gives suggestions as to when you may wish to use them.

Node-RED is renown for its MQTT support since that is where it started - as an IBM demonstrator for their experteese on IoT.

However, this is only one of many ways to send/receive data between Node-RED and other systems or services. Each of tese protocols has its own advantages and disadvantages.

The protocols ๐Ÿ”—๏ธŽ

In rough order of descending order of ease of use (very rough!):

  • MQTT
  • Websocket
  • HTTP
  • TCP
  • UDP
  • UNIX Pipes

MQTT ๐Ÿ”—๏ธŽ

This is likely to be the easiest to use even though it requires an extra service to be running, a โ€œBrokerโ€.

There is even a custom node available that lets you run a broker from within Node-RED itself. However, I donโ€™t recommend doing that because it adds significant overheads that are easily avoided. The most commonly used broker is โ€œMosquitoโ€ which has low resource overheads, is fast, secure and capable. It is easily installed and configured.

While MQTT data payloads are just strings, Node-RED lets you send and receive more complex data structures (JSON).

The things that put MQTT at the top of the list are:

  • The ability to easily handle more complex data
  • The availability of MQTT libraries and clients for many platforms

Websocket ๐Ÿ”—๏ธŽ

HTTP ๐Ÿ”—๏ธŽ

TCP ๐Ÿ”—๏ธŽ

UDP ๐Ÿ”—๏ธŽ

UNIX Pipes ๐Ÿ”—๏ธŽ