Skip to content

Cookie preferences

We use cookies for our own analytics, to see how our campaigns perform and, if you allow it, to load content from other services such as the Google site search. We never sell your data. Necessary cookies keep the site working and cannot be switched off. See our Cookie Policy for details and our Privacy Policy for how we handle personal data.

Security, load balancing and remembering your cookie choice.

Show us which pages people read, how they find the site and where they get stuck, so we can improve it (Google Analytics, Microsoft Clarity).

Show us which of our ad campaigns bring visitors to the site and remember the campaign or partner link you arrived from (Google Ads, LinkedIn, Meta, partner program). We do not use these cookies to build advertising profiles.

Load the site search from Google when you use it. Google sets its own cookies and shows ads in the search results.

© 2026 The ThingsBoard Authors
180 Try for free

ThingsBoard Cloud

Choose your data region

Your data stays in the region you choose, for residency and compliance. No credit card required.

Rather run it yourself? Install on your own servers

TCP Integration

TCP Integration receives data from devices that send it over a TCP connection and converts the payload into ThingsBoard telemetry and attributes. It also supports downlink: the Edge can send a message back over the same connection.

  • A ThingsBoard server with tenant administrator access. The templates are created there.
  • A ThingsBoard Edge instance connected to the server.
  • Docker on the machine that will run the TCP integration service. Port 10560 must be open for incoming connections there.
  • The echo command and netcat (nc) to simulate a device.

The example device SN-002 sends temperature and humidity readings to port 10560. Pick the payload format that matches your device:

SN-002,default,temperature,25.7\r\nSN-002,default,humidity,69

Converter templates are created on the server. The uplink converter decodes the TCP payload into telemetry and attributes. The downlink converter encodes messages from the rule engine, for example shared attribute updates, into the message sent back to the device.

  1. On the server, go to Edge management > Templates and open the Converter tab. Click Add data converter and select Create new converter.

  2. Set Converter type to Uplink, select TCP as the Integration type, and enter the name TCP uplink converter.

  3. In Main decoding configuration, select JS, paste the script for your payload format, and click Add.

    /** Decoder **/
    // decode payload to string
    var strArray = decodeToString(payload);
    var payloadArray = strArray.replace(/\"/g, "").replace(/\s/g, "").split(',');
    var telemetryKey = payloadArray[2];
    var telemetryValue = payloadArray[3];
    var telemetryPayload = {};

To change a converter later, open it on the Converter tab, click the pencil icon, edit the script, and click the checkmark icon. The change is pushed to every Edge that uses it.

  1. On the Converter tab, click Add data converter and select Create new converter.

  2. Set Converter type to Downlink, select TCP as the Integration type, and enter the name TCP downlink converter.

  3. In Main encoding configuration, select JS, paste the following script, and click Add:

    // Encode downlink data from incoming Rule Engine message
    // msg - JSON message payload
    // msgType - e.g. 'ATTRIBUTES_UPDATED', 'POST_TELEMETRY_REQUEST'
    // metadata - key/value pairs with message metadata
    // integrationMetadata - key/value pairs defined in the Integration
    var result = {
    // downlink data content type: JSON, TEXT or BINARY (base64 format)
    contentType: "JSON",
  1. On the server, go to Edge management > Templates, open the Integration tab, and click Add integration.

  2. On the Basic settings step, select TCP as the Integration type. Keep the name TCP integration or enter your own. Click Next.

  3. On the Uplink data converter step, select Select existing, choose TCP uplink converter, and click Next.

  4. On the Downlink data converter step, select Select existing, choose TCP downlink converter, and click Next.

  5. On the Connection step, keep Port at 10560. Under Handler Configuration, select the handler for your payload format and fill in its fields:

    Field Value
    Handler Configuration TEXT
    Max Frame Length (in bytes) 128
    Strip delimiter enabled (removes the newline from the payload)
    Message separator type System line separator
  6. Execute remotely is enabled and cannot be turned off, because TCP Integration runs only as a remote service. Copy the Integration key and Integration secret shown under it. You need them to start the service.

  7. Click Add.

The other socket settings on the Connection step keep their defaults:

Setting Description
Max number of pending connects on the socket Queue length for incoming connection requests. New connections are refused when the queue is full.
Size of the buffer for inbound socket (in KB) Socket receive buffer size.
Size of the buffer for outbound socket (in KB) Socket send buffer size.
Enable sending of keep-alive messages on connection-oriented sockets Sends periodic keep-alive probes to check that the connection is still alive.
Forces a socket to send the data without buffering (disable Nagle’s buffering algorithm) Sends data immediately instead of buffering it.
  1. On the server, go to Edge management > Edges and click the Edge. On the Details tab, click Manage integrations.

  2. Click Assign to edge (+), select TCP integration, and click Assign.

  3. Log in to the Edge and go to Integrations > Integrations. The TCP integration is listed there.

Install and run the remote TCP integration

Section titled “Install and run the remote TCP integration”

The remote service connects to the Edge through the integration RPC port, 9090 by default (INTEGRATIONS_RPC_PORT in tb-edge.yml), and identifies itself with the Integration key and Integration secret of the template. See also Remote integrations.

  1. Pull the image:

    Terminal window
    docker pull thingsboard/tb-tcp-udp-integration:4.4.0.2
  2. Create a directory for the logs:

    Terminal window
    mkdir -p ~/.tb-pe-tcp-udp-integration-logs && sudo chown -R 799:799 ~/.tb-pe-tcp-udp-integration-logs
  3. Start the service. Replace the placeholders with your values:

    Terminal window
    docker run -it -p 10560:10560 \
    -v ~/.tb-pe-tcp-udp-integration-logs:/var/log/tb-tcp-udp-integration \
    -e "RPC_HOST=mytbedge" \
    -e "RPC_PORT=9090" \
    -e "INTEGRATION_ROUTING_KEY=YOUR_ROUTING_KEY" \
    -e "INTEGRATION_SECRET=YOUR_SECRET" \
    --name my-tb-pe-tcp-udp-integration \
    --network NETWORK_NAME \
    --restart always \
    thingsboard/tb-tcp-udp-integration:4.4.0.2
    Parameter Description
    mytbedge Hostname of the Edge service
    9090 Integration RPC port of the Edge
    -p 10560:10560 Publishes port 10560 of the container on the host
    YOUR_ROUTING_KEY Integration key of the template
    YOUR_SECRET Integration secret of the template
    NETWORK_NAME Docker network of the Edge container. Find it with docker network ls.

To detach from the container without stopping it, press Ctrl+p then Ctrl+q. Useful commands:

Terminal window
docker attach my-tb-pe-tcp-udp-integration # reattach to the logs
docker stop my-tb-pe-tcp-udp-integration
docker start my-tb-pe-tcp-udp-integration

Once the service is running, it listens on port 10560.

  1. Send a test message with echo and nc. Pick the command for your payload format:

    One message:

    Terminal window
    echo -e 'SN-002,default,temperature,25.7' | nc -q0 127.0.0.1 10560

    Several messages in one connection, separated by a newline:

    Terminal window
    echo -e 'SN-002,default,temperature,25.7\nSN-002,default,humidity,69' | nc -q1 -w1 127.0.0.1 10560
  2. On the Edge, go to Integrations > Integrations, open the TCP integration, and select the Events tab. An Uplink event with status OK appears.

  3. The device SN-002 is created automatically. On the Edge, go to Devices & assets > Devices, open it, and select the Latest telemetry tab to see the received values.

  4. To see how the converter processed the message, go to Integrations > Data converters, open TCP uplink converter, and select the Events tab. Click the three dots in the In column to see the raw payload, or in the Out column to see the decoded result.

To send messages from the rule engine to the integration, add an integration downlink node to the root rule chain of the Edge.

  1. On the Edge, go to Data processing > Rule chains and open Edge Root Rule Chain.

  2. In the node search field, type integration downlink and drag the integration downlink node onto the canvas.

  3. Enter a name, select TCP integration in the Integration field, and click Add.

  4. Connect the message type switch node to the new node and select the Attributes Updated link label.

  5. Click the checkmark icon to save the rule chain.

The integration sends the downlink over an open TCP connection of the device. In the test below, nc keeps the connection open and prints the response.

  1. On the Edge, go to Devices & assets > Devices, open SN-002, and select the Attributes tab. Select the Shared attributes scope, click +, enter the key firmware and the value v1.0, and click Add.

  2. Open the Events tab of the integration. A Downlink event with status OK appears.

  3. Send an uplink message again, this time keeping the connection open (without -q0):

    Terminal window
    echo -e 'SN-002,default,temperature,25.7' | nc 127.0.0.1 10560

    Several messages:

    Terminal window
    echo -e 'SN-002,default,temperature,25.7\nSN-002,default,humidity,69' | nc -w60 127.0.0.1 10560

    The terminal prints the response from the Edge:

    {"firmware":"v1.0"}