The Edge MicroServer (EMS) and Lua Script Resource (LSR) are Edge software that can be used to connect remote devices to the ThingWorx platform. Using a Gateway is beneficial because, this will allow you to run one instance of the EMS on a server and then many instances of the LSR on different devices all over the world. All communication to the platform will be handled by this one EMS Gateway server. The EMS Gateway can be set up in two different types of scenarios: Self-Identifying Remote Things and Explicitly defined Remote Things.
The scenario I'm going to discuss below will involve explicitly defined Remote Things, a ThingWorx server, an EMS, and a LSR. We will need at least 1 server to run the ThingWorx platform and EMS, but these can always be on separate servers as well. We will also need some other machine or device that will run the LSR.
Visit the support downloads page to find the latest EMS releases. The LSR is contained within the EMS download.
You can also navigate to the Edge Support site to read more about the EMS and LSR oif this is the first time you have ever configured one. The "ThingWorx WebSocket-based Edge MicroServer Developer's Guide" is also provided inside of the zip file that contains the EMS for further information.
Once we have obtained the EMS download from the support site (see the section above for links) we can begin creating our config.json file.
The image below is a working config.json file for using the EMS as a Gateway. The settings in here are particular to my personal IP addresses and Application Key, but the concept remains the same, and I will go into further detail on the necessary sections, below the image.
All further reading on the sections of the config.json file can be found in the config.json.complete file included with the EMS download and on the Edge Help Center under the "Creating a Configuration File" section and the "Viewing All Options" section.
In this example, the LSR is going to run on a separate server and point to the EMS server. Below is a screenshot of two very important additions (rap_host and rap_port) to the default config.lua file:
Now that we have configured the LSR and EMS to point to each other and the platform we can try running both of these applications to make sure we are successful.
Any further questions about browsing remote properties or other configuration settings in the .config files is most likely addressed in the Edge Help Center under the EMS section, and if not, feel free to comment directly on this document.
Really great guide.
I have one question regarding the Gateway itself where the EMS is running on in the autobind section "EdgeGateway".
Does that mean that I need to model the Gateway as well as a thing on the platform? I'm asking because I can scale the Naming and registering of the "OtherEdgeThing", because the LSR is running on the equipment, which has a unique serial number.
But do all the gateways need to be modelled as a seperate thing?
Regards,
Pascal
Okay I googled this: Digital Media Publisher, and there it's explained that you can use always the same Thing EdgeGateway until an LSR has connected through the gateway on the plattform.
So, if you have 2000 things connected in the field with #2 each on #1 gateway, making it 2000 things and 1000 gateways, I only need to create 2001 things on the platform, 2000 things for LSR and 1 general EMSGateway thing, correct?
Does that make sense?
Thanks,
Pascal
Correct, you would only need 1 gateway for all your LSRs, but in a real world scenario you might want to scale that a bit differently. 2000 devices connecting to one gateway may have some performance issues.
Thanks Meghan Hollenbach! 2000 things per device really do no not make sense - what I meant was on the platform - do I need to model each gateway as at thing as well?
Regards,
Pascal
You would want to model one Thing on the platform for each LSR to bind to, yes. The Gateway Thing will be ephemeral if you did not create one, so you really do not need to worry about creating a GatewayThing to bind with the EMS.
Meghan
In my situation, I have a seven smart, internet capable devices in a single building. However, I want all communication to the cloud to go through a local server within the building running the EMS in gateway mode. In this scenario, would my seven smart devices also contain the EMS application?