Sending Messages Between Systems
- Updated2025-10-28
- 3 minute(s) read
Use messages to send commands, status updates, or data, such as JSON, between systems and applications. Messages operate as a network queue, which uses the publish/subscribe model.
What to Use
What to Do
- Create the following diagram in a VI to subscribe to and read messages.
Customize the gray sections for your unique programming goals.

1 Open Configuration initiates a connection with a SystemLink server. 2 Open creates a message session with the server, which allows you to subscribe to a message queue. 3 Subscribe registers an endpoint, such as a web application, to a specific topic. Note Subscribers of a topic receive every message published to that topic beginning from the point they subscribe. They do not receive or have access to messages sent before that point.4 Read returns a message from the queue. If there are no queued messages, the call synchronously blocks up to the timeout specified or to the maximum timeout defined by the web server, whichever is smaller. If you leave the timeout milliseconds input unwired, the Read node has a default timeout of 100 milliseconds. In this example, the timeout is set to 2000 milliseconds.NoteNI Web Server has a maximum timeout of 10 seconds. You can edit the timeout for the NI Web Server.
To adjust the timeout for NI Web Server, edit the configuration file of the server. Refer to Configuring NI Web Server more information.
Use Unflatten from JSON when using Read to make messages easier to parse from a web browser.
Use a While Loop to continue reading messages until a condition is met. In this example, the node reads messages until there is an error.
- Create the following diagram in a VI to publish messages.
Customize the gray sections for your unique programming goals.

1 Open Configuration initiates a connection with a SystemLink server. 2 Open creates a message session with the server, allowing you to publish messages to a message queue. 3 Publish writes a message to a topic. If multiple messages are published, the subscriber reads the messages in the order they are received. Use Flatten to JSON when using Publish to convert LabVIEW data types to string, which is the only data type messages support, and to easily interact with the data when reading messages in LabVIEW and other JSON-supported languages.
Use a Case Structure to set up conditions for when to publish. In this example, Publish write messages until you move the Publish switch to the off position on the panel.
Use a While Loop to continue publishing tags until a condition is met. In this example, Publish writes messages until there is an error.
4 Close terminates the message session with the server. 5 Close Configuration cleans up connections associated with the configuration by invalidating any open references to created objects.
Troubleshooting
- Call Subscribe before calling Read. You must subscribe to a topic before your program will read a message.
- Verify that you are subscribed to the right topic before running the code.
Note Topics are case sensitive.
Related Information
- SystemLink API Reference
- Transferring Data Using Tags
Use tags to send and receive data from one system to other systems.
- Configuring NI Web Server