- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Introduction
In this article, a method of exposing a ctrlX CORE to be accessed over the internet is explained. Specifically, the use case of a REST API endpoint hosted in Node-Red is covered. A Netgear RAX45 router is used in this example, but the same principles apply to all devices.
Prerequisites
An understanding of REST API methods will be useful in following this example. The specifics behind the structure of requests are not explained.
Useful Links
Node-Red Communication Methods
Instruction
Step 1: Port Forwarding Configuration
In order to to access the Node-Red flow editor of a ctrlX CORE on a seperate network, port forwarding rules should be configured in the router. The ctrlX CORE is a network participant, so all external traffic must be forwarded to the CORE, through the router which has an internet connection. The ctrlX CORE web interface and Node-Red application run on the HTTPS port. This is the internal port in the port forwarding rule configuration and is 443 by default. The external port can be chosen by the user, so long as it is not already in use by another application. In this example, 55555 is provided as the external port. The internal IP address on the CORE local area network must also be included in the rule. A single port is forwarded in this case, but a range could be used as well.
Once this port is forwarded, the ctrlX CORE web interface and Node-Red flow editor should be accessible from a seperate network via the internet. The URL to access the web interface can be built as shown below.
https://{External IP Address}:{External Port}
To find the external IP address of the router, a web page like the following can be used: https://myexternalip.com/
Step 2: Create Node-Red REST API Endpoint
To create an endpoint that will accept writing over REST API POST request, use an HTTP In node and set the method to POST. The URL is user choice and will set the endpoint address. In this example, the endpoint URL is then:
https://{External IP Address}:{External Port}/node-red/Example-Endpoint
Now, the endpoint should accept a POST request from an external source, so long as the sender accepts self signed certificates. The request below was configured in Postman.
The image below shows the data arriving at the endpoint in Node-Red. A response to the request is also sent back to the sender to indicate the successful operation. The flow is attached as type .txt at the bottom of the article.
Other endpoints on the ctrlX CORE datalayer can also be written to and read from using this method (e.g. PLC variables), with proper authentication. Please reference the first useful link for further information on this topic.