thingsboard-gateway icon indicating copy to clipboard operation
thingsboard-gateway copied to clipboard

[HELP]Local MQTT connector `ModuleMQTT` (configuration `moduleMqtt.json`) is not loaded when `remoteConfiguration` is false

Open JamesLebron opened this issue 4 weeks ago • 2 comments

Describe the issue

I am running ThingsBoard IoT Gateway on an embedded ARM Linux board (Buildroot-based, Rockchip RK3566).

During development, I configured and tested an MQTT connector using Remote Configuration in the ThingsBoard UI. It worked correctly.

Now I want to productize this connector so that all gateways use a local connector configuration instead of remote configuration.

I did the following:

  1. Copied the working MQTT connector configuration from remote configuration to a local file moduleMqtt.json under /etc/thingsboard-gateway/config/.
  2. Updated /etc/thingsboard-gateway/config/tb_gateway.json to register this connector:
    "connectors": [
      {
        "type": "mqtt",
        "name": "ModuleMQTT",
        "configuration": "moduleMqtt.json"
      }
    ]
    
  3. Set "remoteConfiguration": false in tb_gateway.json because I want to use only local configuration.
  4. Started the gateway manually with:
    thingsboard-gateway 
    

Expected behavior

  • The local MQTT connector ModuleMQTT should be loaded on startup.
  • I expect to see log lines like Starting MQTT connector ModuleMQTT ... and connector-specific logs in connector.log.
  • In statistics, connectorsStats should contain an entry for ModuleMQTT.
  • The gateway should try to connect to the external MQTT broker defined in moduleMqtt.json.

Actual behavior

  • The gateway itself starts successfully and connects to ThingsBoard, but the local MQTT connector does not appear to be loaded.
  • Console output shows messages like:
    Connector with id c5cdde8b-9ca5-4035-b4f5-b3fe261ccc0f not found, trying to use default connector...
    Connector with id c5cdde8b-9ca5-4035-b4f5-b3fe261ccc0f not found, trying to use default connector...
    Connector with id c5cdde8b-9ca5-4035-b4f5-b3fe261ccc0f not found, trying to use default connector...
    Cannot use TLS connection on this port. Client will try to connect without TLS.
    [STRLAN ONLY] 2025-12-08 16:58:38,277 - INFO - tb_gateway_service - Start checking new gateway attributes...
    [STRLAN ONLY] 2025-12-08 16:58:38,284 - INFO - tb_gateway_service - Gateway core started
    [STRLAN ONLY] 2025-12-08 16:58:38,293 - INFO - tb_gateway_service - Gateway connected to ThingsBoard
    [STRLAN ONLY] 2025-12-08 16:58:38,303 - INFO - tb_gateway_service - Persistent device storage created
    [STRLAN ONLY] 2025-12-08 16:58:38,305 - INFO - tb_gateway_service - Gateway started.
    [STRLAN ONLY] 2025-12-08 16:58:38,319 - INFO - statistics_service - Collected requests statistics...
    
  • connectorsStats is always {}, which suggests that no connector is actually active.
  • I do not see any log line indicating that ModuleMQTT is started, nor any connection attempts to the external MQTT broker defined in moduleMqtt.json.
  • The UUID c5cdde8b... looks like it belongs to an old remotely-configured connector. My understanding, however, is that when "remoteConfiguration": false is set, the gateway should ignore any remote connector definitions and only use the local connectors array from tb_gateway.json.

So the core issue is:

Even though the local MQTT connector ModuleMQTT (configuration file moduleMqtt.json) is correctly listed in tb_gateway.json and the file exists in the config directory, it is not loaded/started when using local configuration mode.

JamesLebron avatar Dec 08 '25 18:12 JamesLebron

Hi @JamesLebron, thanks for your interest in ThingsBoard IoT Gateway! We will try to reproduce your issue and let you know about the result. So, let's stay in touch!

samson0v avatar Dec 09 '25 06:12 samson0v

Hello ThingsBoard Team,

I would like to provide supplementary details regarding my specific use case and test results to help diagnose the issue.

Environment

  • ThingsBoard IoT Platform: 4.2.1 (Docker Deployment - docker pull thingsboard/tb-postgres:4.2.1)
  • ThingsBoard Gateway: 3.8.0

Use Scenario

  1. Runtime: Embedded Linux running ThingsBoard Gateway via Python source code.
  2. Devices: Two Linux applications running within the embedded Linux system act as virtual devices.
  3. Connectivity: These two virtual devices connect to the Gateway using the official MQTT Connector.
  4. Status: The MQTT connector has been fully configured with the required business parameters.

Note: Based on this scenario, the complete solution has been tested and verified locally.

Expected Deployment Flow

I aim to perform a batch deployment based on the verified solution:

  1. File Preparation: Place the two core configuration files into the embedded file system:
    • tb_gateway.json (Includes host, remoteShell, remoteConfiguration, storage, grpc, connectors, etc.)
    • mqtt_connector.json (Specific MQTT configuration)
  2. Auto-Provisioning: On the first run, the Gateway should automatically initialize itself (create a Gateway device on the Platform) using the provisioning section in tb_gateway.json.
    "provisioning": {
       "type": "ACCESS_TOKEN",
       "deviceName": "Gateway-xxxxxxxxxxxx",
       "provisionDeviceKey": "xxxxxxxxxxxx",
       "provisionDeviceSecret": "xxxxxxxxxxxx"
    }
    
  3. Config Sync (Gateway): After initialization, with remoteConfiguration=true, the Gateway should automatically sync settings (remoteShell, storage, grpc, connectors, etc.) from tb_gateway.json to the IoT Platform.
  4. Config Sync (Connectors): The Gateway should automatically load mqtt_connector.json and sync the verified MQTT configuration to the IoT Platform via remoteConfiguration=true.

Actual Test Results (Provisioning Flow)

1. Success:

  • The Gateway auto-provisioning process works correctly.

2. Anomalies/Bugs:

  • (1) Version Missing: The IoT Platform does not display the Gateway software version.
  • (2) Gateway Config Sync Failure: Configurations in tb_gateway.json (remoteShell, remoteConfiguration, storage, grpc, connectors) are not synced to the IoT Platform. When I attempt to modify these configurations on the IoT Platform, the Gateway only logs the following:
    tb_gateway_service - __process_remote_logging_update - 693 - Remote logging level set to: NONE 
    
  • (3) Connector Sync Failure: mqtt_connector.json is not loaded or synced to the IoT Platform (no connectors are displayed in the dashboard).
    • If I manually create a connector on the IoT Platform, the UI shows "Success", but the Gateway outputs no logs/response.

Additional Investigation (Access Token Flow)

Suspecting the issue might be related to the auto-provisioning process, I adjusted the workflow for testing. I manually created a Gateway device on the platform and configured tb_gateway.json to log in using the security section (Access Token).

1. Results:

  • Login: Successful. The IoT Platform correctly displays the Gateway version.
  • Gateway Config Sync: Configurations in tb_gateway.json (remoteShell, storage, grpc, etc.) are successfully synced to the IoT Platform. Modifying configurations (e.g., storage) on the platform syncs back to the Gateway correctly.

2. Remaining Issues:

  • Connector Sync Failure Persists: mqtt_connector.json is still not loaded/synced to the IoT Platform (no connectors displayed).
  • If I manually create an MQTT connector on the IoT Platform, the UI shows success. However, when I try to modify the connector configuration, it does not sync to the Gateway. Instead, I receive the following error log:
    Cannot find separated report strategy for connector 'TEST_MQTT_CONNECOTR'.
    The main report strategy will be used as a connector report strategy.
    

Summary Table

I have compiled a comparison table of the test results below:

Feature Auto-Provisioning Flow Manual Access Token Flow
Login/Connection Success Success
Version Display Failed (Not shown) Success
Main Config Sync (tb_gateway.json) Failed Success
Connector Config Sync (mqtt_connector.json) Failed Failed (with error log)

Log

Provisioning Flow

Provisioning Flow.log

Access Token Flow

Access Token Flow.log

JamesLebron avatar Dec 10 '25 03:12 JamesLebron

Hi @JamesLebron, you have to execute the following commands:

sudo chown thingsboard_gateway:thingsboard_gateway /etc/thingsboard-gateway/config/your-connector-configuration.json
sudo chmod 644 /etc/thingsboard-gateway/config/your-connector-configuration.json
sudo systemctl restart thingsboard-gateway

Let me explain:

  1. You created a connector configuration file as a root user or different from thingsboard_gateway
  2. Gateway service doesn't have access to this file because the owner is different
  3. You need to update the rights to this file or create configuration files under the thingsboard_gateway user

We will mention this situation in the documentation.

After initialization, with remoteConfiguration=true, the Gateway should automatically sync settings (remoteShell, storage, grpc, connectors, etc.) from tb_gateway.json to the IoT Platform.

It is not possible, because if you have remote configuration enabled, a higher priority has remote settings. Also, we mentioned this in the official documentation.

Image

samson0v avatar Dec 17 '25 10:12 samson0v

@JamesLebron, also this can help you: https://github.com/thingsboard/thingsboard-gateway/issues/2034#issuecomment-3645717934

samson0v avatar Dec 17 '25 10:12 samson0v