ThingWorx Edge MicroServer (EMS) > EMS and ThingWorx Platform
EMS and ThingWorx Platform
The EMS is a stand-alone application that you can install on a remote device. Once configured and running, the EMS establishes AlwaysOn, bidirectional communications between the device and the ThingWorx Platform. The EMS uses a small footprint, and supports a variety of operating systems and architectures. This flexibility allows the EMS to work with a large number of devices to provide an easy way to establish communication between an edge device and a ThingWorx Platform instance. You can use ThingWorx Composer to interact with the edge devices that are running the EMS, and using ThingWorx Mashup Builder, you can build interactive, browser-based mashups for users who monitor the devices..
The sections listed below provide additional information about connecting devices to a ThingWorx Platform. Click the title of a section to display its content; click the title again to hide the content:
The Connection Sequence 
The process of connecting to a ThingWorx Platform instance consists of three main steps: Connect, Authenticate, and Bind. The EMS performs the first two steps. Then, the EMS works with the Lua Script Resource or a custom application to perform the third step. Here are the steps in more detail:
1. Connect — The EMS opens a physical WebSocket to a ThingWorx Platform instance, using the host and port specified in its configuration file. If configured, SSL/TLS is negotiated at this time.
2. Authenticate — The EMS sends an authentication message to the ThingWorx Platform instance. This message must contain an application key that was previously generated by an administrator user.
Upon successful authentication, the EMS can interact with the ThingWorx Platform instance, according to the permissions applied to its application key. For the EMS, this implies that any client that makes HTTP calls to its REST interface can access functionality on the ThingWorx Platform instance. For this reason, the EMS is set by default to listen for HTTP connections on localhost (port 8000). You can change this listening port in the configuration file for the EMS.
At this point, the EMS can make requests to the ThingWorx Platform instance and interact with it, much like an HTTP client can interact with the REST interface of the platform instance, but the instance cannot direct requests to the Edge device.
3. Bind — To enable the ThingWorx Platform instance to send requests to the EMS, the EMS works with the Lua Script Resource (or custom application) to send a BIND message to the ThingWorx Platform instance on behalf of the devices. Note that this step is optional, if you do not want the devices to receive and process requests from the platform instance. It is required if you want to transfer files from the platform instance to your devices or if you want to use tunneling.
The BIND message can contain one or more names or identifiers for the devices. Note that corresponding Remote Things must have been created on the ThingWorx Platform instance to represent your edge devices. Remote things are things that are created using the RemoteThing Thing Template (or one of its derivatives) in ThingWorx Platform. When it receives the BIND message, the platform instance associates the matching Remote Things that it has with the WebSocket that received the BIND message. This association allows the instance to use the WebSocket to send requests to the edge devices, and update the isConnected and lastConnection time properties for the corresponding Remote Things on the ThingWorx Platform instance.
The EMS can send an UNBIND message to the ThingWorx Platform instance that removes the association between the Remote Things on the instance and the WebSocket. The isConnected property is then updated to false.
Deployment 
Once you have properly configured and integrated the EMS and Lua Script Resource (or your custom application), you can deploy them in one of the following ways:
Embedded Deployment — Integrate the EMS and Lua Script Resource (or your custom application) directly into the application software stack of the edge device.
Tethered Deployment — Deploy the EMS to a simple black-box that connects to the diagnostic and sensor ports of an intelligent device. Deploy the Lua Script Resource or your custom application either on the same black-box, or on the intelligent device.
Networked Gateway Deployment — Deploy the EMS on a simple server appliance that exists on the same network as a set of intelligent devices (for example, sensor networks or clusters of network-capable equipment),. Then, deploy the Lua Script Resource or your custom application on other hardware on the same local network.
Configuration Overview 
To start connecting your edge devices to a ThingWorx Platform instance, you need to do the following:
1. Begin the initial configuration of the EMS, as described in Configuring the EMS.
2. PTC strongly recommends that you configure and use SSL/TLS certificates for communications between your edge device that is running the EMS and the ThingWorx Platform. If required, you can also use SSL/TLS certificates for communications between your EMS and the edge devices that are running the Lua Script Resource (LSR).
If you do not have your own SSL/TLS certificates, refer to Using a Custom Certificate and Private Key for information on creating a custom certificate and private key and configuring the EMS and LSR to use them.
* 
As of v.5.4.5 of the EMS, the built-in certificate is no longer provided. You need to migrate to using a custom certificate. Refer to Migrating from the EMS/LSR Built-in Certificates for more informatinon.
3. Once you have successfully connected to the ThingWorx Platform instance, complete the full configuration of the EMS according to your needs. Refer to the section, Viewing All Configuration Options.
4. To use the Lua Configuration Script to host Remote Things for integration with ThingWorx Platform, configure the Lua Script Resource, as described in Getting Started with the Lua Script Resource.
Was this helpful?