Skip to content
Stand with Ukraine flag

Socket

The Socket Connector runs a TCP or UDP server on the gateway, accepting connections from devices and forwarding their binary payload data to ThingsBoard.

To enable this connector, add it to the connectors list in tb_gateway.json — see the General Configuration reference.

General settings for the connector — name, logging, change filtering, and the report strategy.

  • Name — connector name, used in logs and when saving to persistent storage
  • Enable remote logging — enables remote logging for the connector
  • Logging levelINFO, DEBUG, WARNING, ERROR, CRITICAL, or NONE
  • Send data only on change — sends data only when its value has changed; otherwise data is sent on every check
  • Report strategy — controls when data is forwarded to ThingsBoard:
    • On report period — after every report period
    • On value change — when a value changes
    • On value change or report period — when a value changes or the report period elapses
    • On received — immediately after data is received from the device (default)

Configures the local socket the connector binds to.

Configure the following fields:

  • Connection typeTCP or UDP
  • Address — IP address to bind to
  • Port — port to listen on
  • Buffer size — size of the received data block buffer

An array of device configurations. Only devices whose IP address matches addressFilter are accepted; all other connections are rejected.

Click the plus icon to add a new device, then fill in the following fields:

  • Address filter — IP address pattern allowed to connect (see examples below)
  • Device name — device name in ThingsBoard
  • Device profile — device profile in ThingsBoard (optional)
  • Encoding — encoding used when writing string data to storage

Address filter examples — for a device at 192.168.0.120:5001:

Address filterMatches
192.168.0.120:5001Only that exact IP address and port
*:5001Any IP address on port 5001
192.168.0.120:*That IP address on any port
*:*Any IP address on any port

Subsections “Time series” and “Attributes”

Section titled “Subsections “Time series” and “Attributes””

Both use a binary byte-slicing converter. Values are extracted from the raw incoming payload by specifying start and end byte positions.

  1. Click the pencil icon of the Attributes section to add a new attribute key.

  2. Click Add attribute in the opened window.

  3. Enter the key name and byte positions, then click Apply.

  4. Click the pencil icon of the Time series section to add a new time series key.

  5. Click Add time series in the opened window.

  6. Enter the key name and byte positions, then click Apply.

You can enable a per-key report strategy. Available strategies:

  • On report period — after every report period
  • On value change — when a value changes
  • On value change or report period — when a value changes or the report period elapses
  • On received — immediately after data is received (default)

Optional. Lets the device request client-side or shared attributes from ThingsBoard by sending a specially formatted binary message.

  1. Click the pencil icon of the Attribute requests section.

  2. Click Add attribute request in the opened window.

  3. Select the request type, enter the request expression and attribute name expression, then click Apply.

Optional. Configures how ThingsBoard shared attribute updates are forwarded to the connected device.

  1. Click the pencil icon of the Attribute updates section.

  2. Click Add attribute update in the opened window.

  3. Select encoding and fill in the Attribute on platform field, then click Apply.

Optional. Maps ThingsBoard RPC calls to write operations on the connected device.

  1. Click the pencil icon of the RPC methods section.

  2. Click Add method in the opened window.

  3. Fill in Method name, select encoding, and set With Response, then click Apply.

Every telemetry and attribute key also has a built-in set RPC method available automatically — no manual entry required. The required parameters are withResponse, methodProcessing, and encoding. See the Reserved RPC methods guide for details.