This guide will help you get familiar with Socket Connector configuration for ThingsBoard IoT Gateway.
Use the general configuration guide to enable this Connector. It’s purpose
is to connect to your server using TCP or UDP connection type.
This Connector is useful when you have a local server in your facility or corporate network and want to push
data from the server to ThingsBoard.
We will describe the connector configuration file below.
Please note: If you are new to IoT Gateway, use the “Basic” configuration mode. If you are familiar with configuring IoT Gateway, you can use the “Advanced” configuration mode.
Connector configuration
Connector configuration is a UI form that contains information on how to connect to an external server, how to process
the data and other service features. Let’s review the format of the configuration file using the example below.
Let’s take a comprehensive look at all the available settings. We will go through each option in detail to ensure
that we thoroughly understand their functions and implications. By doing so, we can make well-informed decisions about
which settings will best suit our needs and preferences.
Section “General”
This configuration section contains general connector settings, such as:
Name - connector name used for logs and saving to persistent devices;
Logs configuration:
Enable remote logging - enables remote logging for the connector;
Logging level - logging level for local and remote logs: INFO, DEBUG, WARNING, ERROR, CRITICAL, NONE;
Send data only on change - sends data only it has changed since the last check, otherwise – data will be sent after every check;
Report strategy - strategy for sending data to ThingsBoard:
Report period - period for sending data to ThingsBoard in milliseconds;
Type - type of the report strategy:
On report period - sends data to ThingsBoard after the report period;
On value change - sends data to ThingsBoard when the value changes;
On value change and report period - sends data to ThingsBoard when the value changes or report period;
On received - sends data to ThingsBoard after receiving data from the device (default strategy).
Additional information about the report strategy can be found here.
The settings are the same for both the basic and advanced configurations.
Section “Socket”
The “Socket” section is used for configuring socket connection settings.
This configuration section contains an array of objects that contains clients that can be connected to the connector and
send the data. Any connection not included in this array will be rejected by the connector.
Let’s review more examples of IP addresses filtering:
For example, we have a device that has the following IP address: 192.168.0.120:5001. Now, let’s look at configuration examples
of the field to allow connections with different IP address variants:
Only one device with a specified IP address and port can connect:
Address filter: 192.168.0.120:5001
Allow any devices with any IP address, but only port 5001:
Address filter: *:5001
Allow all devices that have the IP address 192.168.0.120 with any port:
Address filter: 192.168.0.120:*
Allow all devices with any IP address and any port:
Address filter::
Subsection “Time series” and “Attributes”
This configuration section includes the parameters for handling incoming data.
This converter is designed for binary payloads. It directly interprets binary data to retrieve attributes and
time series, using specific byte positions for data extraction.
To add new time series or attribute key, follow these steps:
Click “pencil” icon of the “Attributes” section to add new attribute key;
Click on “Add attribute” in the opened window;
Enter the key name and fill in the byte positions. Click “Apply”;
Now click on the “pencil” icon of the “Time series” section to add new time series key;
Click on “Add time series” in the opened window;
Enter the key name, fill in the byte positions and click “Apply”.
Click “pencil” icon of the “Attributes” section to add new attribute key;
Click on “Add attribute” in the opened window;
Enter the key name and fill in the byte positions. Click “Apply”;
Now click on the “pencil” icon of the “Time series” section to add new time series key;
Click on “Add time series” in the opened window;
Enter the key name, fill in the byte positions and click “Apply”.
You can enable a specific report strategy for each time series or attribute. This strategy defines how often
data is sent to the ThingsBoard server. The following strategies are available:
On report period - sends data to ThingsBoard after the report period;
On value change - sends data to ThingsBoard when the value changes;
On value change and report period - sends data to ThingsBoard when the value changes or report period;
On received - sends data to ThingsBoard after receiving data from the device (default strategy).
Additional information about the report strategy can be found here.
This converter is designed for binary payloads. It directly interprets binary data to retrieve attributes and
time series, using specific byte positions for data extraction.
Parameter
Default value
Description
telemetry
This subsection contains parameters of the incoming message, that will be interpreted as telemetry for the device.
… key
temp
Name for telemetry in ThingsBoard.
… byteFrom
0
Used to slice received data from the specific index.
… byteTo
-1
Used to slice received data to the specific index.
attributes
This subsection contains parameters of the incoming requests, that will be interpreted as attributes for the device.
… key
hum
Name for attribute in ThingsBoard.
… byteFrom
2
Used to slice received data from the specific index.
… byteTo
4
Used to slice received data to the specific index.
The attributes section uses the same parameters as the telemetry section.
Additionally, you can request multiple attributes at once. Simply add one more slice expression to
attributeNameExpression parameter. For example, if we want to request two shared attributes in a single request, our config
will look like this:
This means that we have to send the following message to request two shared attributes:
atr sharedAttribute sharedAttribute1
Subsection “Attribute update”
This configuration section is optional.
ThingsBoard allows the provisioning of device attributes and fetches some of them from
the device application. You can treat this as a remote configuration for devices, enabling them to request
shared attributes from ThingsBoard. See user guide for more details.
Also, every telemetry and attribute parameter has a built-in SET RPC method out of the box, eliminating the need for
manual configuration. To use them, make sure you set all the required parameters (in the case of Socket Connector,
these are the following:
withResponse, methodProcessing, encoding).
See the guide.
Next steps
Explore guides related to main ThingsBoard features: