How-To Guides
Integration Guides

Set Up Edge Cascading with the NATS Connector

13min

Review the following guide for setting up Edge Cascading, which is an integration of multiple Manufacturing Connect Edge instances with a NATS connector.

Before You Begin

  • Ensure that every Manufacturing Connect Edge instance that will be used to set up the NATS Proxy connection is on version 3.3.1 or newer.
  • Determine which Manufacturing Connect Edge instance(s) will be the NATS server (host the API access account), and which Manufacturing Connect Edge instance(s) will be the NATS client (host the NATS connector). The NATS server and the NATS client can both send and receive the data going through the NATS proxy connection.
  • If your network has a firewall, make sure it allows port 4222.

Use Case: Set up Edge Cascading with One NATS Client and One NATS Server

Review the following use case to set up two Manufacturing Connect Edge instances with Edge Cascading. Manufacturing Connect Edge A (Server) is the NATS Server and Manufacturing Connect Edge B (Client) is the NATS Client. You will be able to view data from the NATS Server.

Step 1: Enable NATS Proxy (NATS Server)

You will need to enable the NATS Proxy connection in Manufacturing Connect Edge A (Server). The connection is disabled by default.

To enable NATS Proxy:

  1. In Manufacturing Connect Edge A (Server), navigate to System > Tokens.
  2. In the NATS Proxy section, click the Disabled toggle to Enabled.
Enable/Disable toggle for NATS Proxy
Enable/Disable toggle for NATS Proxy


Step 2: Create and Configure Access Account (NATS Server)

You will now need to enable a NATS server. To do this, you will need to create an access account. Once you create the account, copy the API key that you will use to set up the NATS integration connector.

To create the access account:

  1. From Manufacturing Connect Edge A (Server), navigate to System > Tokens.
  2. From the Access Accounts section, click the Add icon. The Create API Account dialog box appears.

    Add Access Account icon
    Add Access Account icon
    
  3. Enter a name for the account and ensure the Enable Account checkbox is selected.
  4. Click Create Account.
  5. Click the Action menu for the account you just created and select Edit topics.

    Edit topics option
    Edit topics option
    
  6. In the Read Topics field, enter the relevant NATS topics and click Add Read Topic for each one. Ensure that you follow proper NATS topics conventions for topic names. By default, a wildcard topic is created (>). This topic will read all topics.
  7. In the Write Topics field, enter the relevant NATS topics and click Add Write Topic for each one. Ensure that you follow proper NATS topics conventions for topic names. To create a wildcard topic, enter > for the topic name.
  8. When done entering read and write topics, click Update.
  9. Click the Action menu again for the account and select View API Key.
  10. Click the Copy icon for the API key and paste it somewhere so you can access it later.

    Copy API Key icon
    Copy API Key icon
    

Step 3: Create NATS Integration Connector (NATS Client)

You will now have to set up the NATS Client by creating a NATS integration connector.

To create the NATS Integration Connector:

  1. From Manufacturing Connect Edge B (Client), navigate to Integration.
  2. Click the Add a connector icon. The Add a connector dialog box appears.
  3. Use the Provider drop-down list to select the NATS connector.

    NATS connector
    NATS connector
    
  4. Enter the details for the connector.
    • Name: Enter a name for the connector.
    • Hostname: Copy the URL of the Manufacturing Connect Edge instance with the NATS server and the access account you previously created. For example, if the URL of the instance with the NATS server is https://192.168.0.175, enter 192.168.0.175.
    • Port: Verify the default port is correct and make any necessary changes.
    • NATS Username: You can leave the field blank.
    • NATS Password: This field is required. Paste the API key you copied from the access account you previously created.
    • Default topic name: Enter a default topic name. The default topic name does not need to have data and does not need to present in all systems sending/receiving data. It can also be overwritten. It will be used later to view the data from the NATS connection.
    • Enable TLS secure connection: Make sure the check box is selected. This allows the connector to successfully connect with the NATS server.
    • Insecure skip verify: Make sure the check box is selected. This allows for a successful connection with a NATS server that may have a self-signed certificate that is not formally recognized by a certificate authority.
    • Throttling limit: You have an option to enter a throttling limit.
    • Persistent storage: You have the option of selecting this option. When enabled, this will cause messages to undergo a store-and-forward procedure. Messages will be stored within Manufacturing Connect Edge when cloud providers are online.
    • Queue Mode: Select the queue mode as lifo (last in first out) or fifo (first in first out). Selecting lifo means that the last data entry is processed first, and selecting fifo means the first data entry is processed first.
  5. Click Add.

Step 4: Enable the Connector

After adding the connector, click the toggle in the connector tile to enable it.

Document image


If you see a Failed status, you can review the Connector Logs and relevant error messages.

Step 5: Add Device

Now that you've set up the connection between the NATS Server and NATS Client, you can create the DeviceHub device that will store the tags that will be used to create topics for the NATS connector.

From Manufacturing Connect Edge B (Client), follow the steps to Connect a Device.

Make the following configurations:

  • Select Device Type Simulator and Driver Name Generator. You have the option of setting up a different device to your specific requirements.

Step 6: Add Tags

After connecting the device, you can Add Tags to the device. The tags will be used to create topics in the NATS connector.

Step 7: Create Topics for Connector

You will need to create topics in the NATS connector you created.

To create connector topics:

  1. From Manufacturing Connect Edge B (Client), navigate to Integration.
  2. Click the NATS connector tile. The connector Dashboard displays.
  3. Click the Topics tab.

    Topics tab
    Topics tab
    
  4. Click the Import from DeviceHub tags icon. The DeviceHub Import dialog box appears.

    Import from DeviceHub tags icon
    Import from DeviceHub tags icon
    
  5. Select the check box to import all tags from the device you created earlier and click Import.

    DeviceHub Import dialog box
    DeviceHub Import dialog box
    
  6. Click the Enable all topics icon.

    Enable all topics icon
    Enable all topics icon
    
  7. Return to the Integration pane and toggle the connect option to enable the connection between the connector and the NATS server.
  8. If the tile status shows CONNECTED, the connection was successfully set up.

Step 8: View Data

Once the connection is successfully set up, you can use the Flows Manager or Analytics in the NATS Server to view data from the connection.

Before You Begin

You will need to use the default topic name you configured for the NATS connector in the NATS Client. Click the Edit icon for the NATS connector tile and copy the default topic name.

Default topic name
Default topic name


View Data in Flows Manager

You can create a flow to view data from the connector topics.

To view data from the Flows Manager:

  1. From Manufacturing Connect Edge A (Server), navigate to Flows Manager.
  2. Navigate to the Flows Manager and create a new flow. See Create a Flow to learn more.
  3. On the flow canvas, drag the Datahub Subscribe node and debug node onto the canvas. Then, connect the two nodes.

    The DataHub Subscribe and Debug nodes
    The DataHub Subscribe and Debug nodes
    
  4. Double-click the DataHub Subscribe node. The Edit DataHub Subscribe node dialog box appears.
    • In the Topic field, paste the default topic name for the NATS connector.
    • If needed, configure the Datahub Subscribe connection. See the Step 3: Configure Connector Nodes section in Create a Flow to learn more.
    • Click Done, and then click Deploy.
  5. Expand the message window beneath the flow to view debug messages.

    The message window
    The message window
    
  6. Click the Debug icon.

    The Debug icon
    The Debug icon
    
  7. Confirm the Debug node is activated and review the messages in the debug window. The "success" :true message confirms the connection is successful.

    Review messages
    Review messages
    

View Data in Analytics

You can view data by using the Analytics canvas.

To view data in Analytics:

  1. From Manufacturing Connect Edge A (Server), navigate to Analytics.
  2. Click Add Processor and select DataHub Subscribe.
  3. In the Topic field, paste the default topic name for the NATS connector.

    Topic name
    Topic name
    
  4. Click Save.
  5. Click the View icon.

    Document image
    
  6. Review the Instance Messages. The "success" :true message confirms the connection is successful.

    Instance Messages
    Instance Messages