ZeroMQ icon

ZeroMQ

Sends or receives ZeroMQ messages as a one-time action

Actions2

Overview

This node enables sending and receiving messages using ZeroMQ sockets within an n8n workflow. It supports various socket types such as Request, Reply, Publish, Subscribe, Push, and Pull, allowing flexible messaging patterns like request-reply, publish-subscribe, and pipeline.

Typical use cases include:

  • Sending commands or data to a service that listens on a ZeroMQ socket.
  • Receiving messages from a ZeroMQ publisher or push socket.
  • Implementing inter-process communication between different parts of a distributed system.
  • Integrating with systems that use ZeroMQ for messaging without writing custom code.

For example, you can use this node to publish updates to multiple subscribers or send a request message and wait for a reply.

Properties

Name Meaning
Socket Type The type of ZeroMQ socket to use. Options: Request (REQ), Reply (REP), Publish (PUB), Subscribe (SUB), Push, Pull.
Action Whether to bind (act as server/listener) or connect (act as client) the socket. Options: Bind, Connect.
Socket Address The address of the ZeroMQ socket, e.g., tcp://127.0.0.1:5555.
Message The message to send (required for Send operation with REQ, PUB, or PUSH socket types).
Topic The topic string used when publishing messages (only for PUB socket in Send operation).

Output

The node outputs JSON objects representing the result of the send or receive operation:

  • Send Operation:

    • For req, pub, and push socket types, each output item contains:
      • success: boolean indicating if the message was sent successfully.
      • sent: the original message sent.
      • topic: (only for pub) the topic used.
      • response: (only for req) the reply received from the remote socket.
  • Receive Operation:

    • For pull, sub, and rep socket types, each output item contains:
      • message: the received message content.
      • topic: (only for sub) the topic of the received message.

    Additionally, for rep socket type, the node automatically sends a response message after receiving.

No binary data output is produced by this node.

Dependencies

  • Requires the zeromq Node.js package to be installed and available.
  • Needs access to a ZeroMQ endpoint specified by the user via the socket address.
  • No special environment variables are required beyond standard network connectivity to the ZeroMQ socket.

Troubleshooting

  • Invalid Socket Type Error: If you select a socket type incompatible with the chosen operation (e.g., trying to send with a pull socket), the node will throw an error. Ensure the socket type matches the operation:

    • Send supports only req, pub, and push.
    • Receive supports only pull, sub, and rep.
  • Connection Issues: Binding or connecting to an invalid or unreachable socket address will cause errors. Verify the socket address format and network accessibility.

  • Message Format Errors: Messages must be strings; ensure the input expression or static value produces a valid string.

  • Timeouts or No Response: When using req socket type, if no reply is received, the node may hang or fail. Confirm the remote service replies properly.

Links and References

Discussion