Skip to main content
Version: 1.8.5

CREATING A THINGWORX CONNECTION

The ThingWorx connector sends the uplinks of your devices to your ThingWorx Platform. It creates a Thing for each device, based on a Thing Template, and updates the Thing with each uplink. It sends to the device the downlinks set on the Thing.

The data follows this path: LoRaWAN® device → ThingPark Enterprise → ThingPark X IoT Flow connection → ThingWorx Platform.

The ThingWorx connector requires that the ThingWorx Platform is installed and configured upfront. This page gives a minimal setup example to get the ThingWorx connector working.

Collecting Expected Information​

Parameters required

UI FieldDescription
NameName of the connection.
HostnameHost name or IP address of the ThingWorx Platform, with or without port, for example thingworx.example.com:8443. The platform must have SSL/TLS enabled.
Application KeySecret access key for accessing the ThingWorx Platform: the Key ID of an application key. See Application Key Retrieval.
Thing Template NameThingWorx Thing Template used to create the Things of the devices. Default actilityThingTemplateSF. The connector creates it when it is missing.
QueryOptional JSON filter that restricts the Things bound to the Thing Template, for example {"filters": {"type": "EQ", "fieldName": "name", "value": "2CF7F1909C0A1A1A"}}.
Connect Timeout (in ms)Maximum time to establish the connection to ThingWorx. Default 30000 ms.
Ping Timeout (in ms)Maximum time to wait for a ping response from ThingWorx. Default 30000 ms.
Default Client Request Timeout (in ms)Default timeout of the requests to ThingWorx. Default 5000 ms.
Client Connect Wait Timeout (in ms)Maximum time to wait for the connection to ThingWorx before the attempt fails. Default 300000 ms.
Query Things Timeout (in ms)Maximum time of the queries that list the Things of the Thing Template. Default 30000 ms.
Invoke Service Timeout (in ms)Maximum time of each service call on ThingWorx, such as the creation of a Thing or its update with an uplink. Default 5000 ms.
Batch Things SizeMaximum number of Things processed in one batch. Default 1000.
DescriptionOptional description of the connection.

Preparing the ThingWorx Platform​

The ThingWorx connector is intended to be connected to the ThingWorx Foundation service. This service can be either provided by ThingWorx as a SaaS service or hosted on local premises.

After enabling the ThingWorx service, retrieve an application key and give the permissions described below to its user.

The connector creates the Thing Template when the connection starts. You can also use your own Thing Template, based on the one created.

Application Key Retrieval​

We recommend that you create a new user or use an existing one that is different from the Administrator user.

  1. Log in to ThingWorx Composer as Administrator (https://<host>:<port>/Thingworx/Composer/index.html) and click the Users link in the Security section of the menu. Click New to add a new user. Add a user in ThingWorx Composer

  2. On the General Information tab, fill in the username and the password, make sure Enabled is checked, and click Save. General information of the ThingWorx user

  3. Click the Application Keys link in the Security section of the menu and click New to create an application key for the new user. Add an application key in ThingWorx Composer

  4. Set the key Name, select the User Name Reference and set an Expiration Date in the future, then click Save. Set the application key in ThingWorx Composer

  5. After you click Save, a Key ID is generated. Copy it: it is the Application Key of the connection. Copy the Key ID of the application key

Permissions Setup​

  1. Click the Collections link in the Permissions section of the menu, select Things and Thing Templates and click Edit Permissions. Edit the permissions of the Things and Thing Templates collections

  2. On the Visibility tab, select the Composer organization and click Save. Visibility of the collections

  3. On the Design Time tab, select the user, check at least the Create and Read permissions and click Save. Design time permissions of the user

  4. Click the Entities link in the Permissions section of the menu, search and select EntityServices and click Edit Permissions. Edit the permissions of EntityServices

  5. On the Visibility tab, select the Composer organization and click Save. Visibility of EntityServices

  6. On the Run Time tab, add the CreateThing, CreateThingTemplate and GetEntityList services, allow the user to execute them and click Save. With these permissions, the connection that uses the application key can create the Thing Template and the Things on the ThingWorx Platform when they are missing. Run time permissions of the user

  7. In the Access Reports link of the Permissions section of the menu, you can check that the user has access to these services. Access reports of the user

  8. You can now log in to ThingWorx Composer with the new user, and use the application key (Key ID) in the connection.

Creating a Connection With UI​

  1. In ThingPark Enterprise, click Connections -> + Add Connection -> ThingPark X IoT Flow. Add a ThingPark X IoT Flow connection in ThingPark Enterprise

  2. In ThingPark X IoT Flow, click ThingWorx in the list of connectors. Select the ThingWorx connector

  3. Fill in the form:

    • Name: a clear name for the connection, for example My ThingWorx Connection.
    • Hostname: the host name or IP address of your ThingWorx Platform, with or without port.
    • Application Key: the Key ID of the application key created in ThingWorx Composer.
    • Thing Template Name: keep actilityThingTemplateSF or enter the name of your Thing Template.
    • Query: optional, a JSON filter on the Things of the Thing Template.
    • Connect Timeout (in ms): optional, default 30000 ms.
    • Ping Timeout (in ms): optional, default 30000 ms.
    • Default Client Request Timeout (in ms): optional, default 5000 ms.
    • Client Connect Wait Timeout (in ms): optional, default 300000 ms.
    • Query Things Timeout (in ms): optional, default 30000 ms.
    • Invoke Service Timeout (in ms): optional, default 5000 ms.
    • Batch Things Size: optional, default 1000.
    • Description: optional. Set your ThingWorx connection
  4. Click Create. A notification confirms that the connection has been created, and the connection details open.

  5. In the connection details, check that the connection is OPENED (see Connection States).

Note

Parameters marked with * are mandatory.

Changing the Settings After Creation​

In the connection details, the settings sections show the settings of the connection.

  1. Click the Edit button next to the setting to change.

  2. Enter the new value and click the Confirm button, then confirm the update.

A notification confirms that the setting is updated.

Creating a Connection With API​

WebSocket Secure (WSS) over TLS v1.2 connection is the recommended protocol by ThingWorx and is mandatory.

You need to create the connection prior to creating the flow.

The creation of a connection establishes a link from ThingPark X IoT Flow to the cloud provider that you want to associate a Device with. The link can be used to transport any Uplink regardless the DevEUI parameter.

To do this, you need to use the Connections group resource:

  • POST /connections to create a new Connection instance
  • PUT /connections to update a Connection instance
  • DELETE /connections to delete a Connection instance
Note

When you update a configuration property on a connection, you must provide the whole configuration properties again.

Example of the creation of a connection:

POST /connections
{
"connectorId": "actility-thingworx-iot",
"name": "Actility ThingWorx Connection",
"configuration":
{
"description": "ThingWorx Datacenter",
"hostName": "thingworx.example.com:8443",
"applicationKey": "{YOUR-APPLICATION-KEY}",
"thingTemplateName": "actilityThingTemplateSF"
}
}

The following table lists the expected results of properties when applied.

PropertyExpected results
connectorIdSet to actility-thingworx-iot
configuration/hostNameDefines the host:port of the ThingWorx Platform to use. Ensure that the platform has SSL/TLS enabled.
configuration/applicationKeySecret access key for accessing the ThingWorx Platform. Required for building the WSS over TLS v1.2 connections.
configuration/thingTemplateNameThingWorx ThingTemplate to be associated with the Things processed by the connector.
configuration/queryJSON filter that restricts the Things bound to the Thing Template, for example {"filters": {"type": "EQ", "fieldName": "name", "value": "2CF7F1909C0A1A1A"}}.
configuration/pipeCountThe pipe count is the number of web sockets that the client opens. The default value of 1 suffices in most applications. Limited to 255.
configuration/connectTimeoutConnect Timeout, in milliseconds. Default 30000.
configuration/pingTimeoutPing Timeout, in milliseconds. Default 30000.
configuration/defaultClientRequestTimeoutDefault Client Request Timeout, in milliseconds. Default 5000.
configuration/clientConnectWaitTimeoutClient Connect Wait Timeout, in milliseconds. Default 300000.
configuration/queryThingsTimeoutQuery Things Timeout, in milliseconds. Default 30000.
configuration/invokeServiceTimeoutInvoke Service Timeout, in milliseconds. Default 5000.
configuration/batchThingsSizeBatch Things Size. Default 1000.
Important note

All properties are not present in this example. You can check the rest of these properties in the common parameters section.

On each Thing, set the property named downlink with a JSON message to send a downlink to the device:

{
"DevEUI_downlink": {
"Time": "2019-07-10T15:38:46.882+02:00",
"DevEUI": "0018B20000000B20",
"FPort": 1,
"payload_hex": "9e1c4852512000220020e3831071"
}
}

For more information, see the downlink message section.

Displaying Information to Know if It Worked​

  1. Go to the ThingWorx Composer dashboard and select the device you want to monitor. Select the Thing of the device in ThingWorx Composer

  2. Click more to see the latest uplink data. Latest uplink of the device in ThingWorx

Limitations​

This connector is limited to 10K devices.

Troubleshooting​

Last Wins Issue​

If you see this error in the events:

Unable to restart connection THINGWORX with id 289: Could not bind things: Error trying to process message: Binding failed, see server log for more information V1BindMessage [header=V1MessageHeader [messageType=10, requestId=21794, endpointId=-1, sessionId=-1, flags=0], gatewayName=null, gatewayType=null, names=[...]]

It is probably due to a ghost connection on the ThingWorx server side. In ThingWorx, set the Last in wins option, in the configuration of the WS communication part.

Last in wins option in ThingWorx

User Rights​

Unable to open connection THINGWORX with id 301: Unable to dispatch [ uri = /Resources/EntityServices/Services/GetEntityList/]: Entity EntityServices does not exist or is not yet associated with a Thing

This error message is related to administration rights. In ThingWorx, make sure that the user has the right to get the entity list (GetEntityList service, see Permissions Setup).