Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT connector buffering #1465

Merged
merged 1 commit into from
Jul 18, 2024
Merged

Conversation

palexandridis
Copy link
Contributor

When subscribing to topics with retain flag set, the mqtt connector can receive all retained messaged since last connection.
Under the broker section in the mqtt json configuration file, two keys have been introduced for MQTT v5.

  • cleanStart which must be false for the buffering to work and
  • sessionExpiryInterval which must be greater than 0.

Example configuration for MQTT v5:

"broker": {
    "name": "Default Local Broker",
    "host": "127.0.0.1",
    "port": 1883,
    "clientId": "ThingsBoard_gateway",
    "version": 5,
    "cleanStart": false,
    "sessionExpiryInterval": 604800,
    "maxMessageNumberPerWorker": 10,
    "maxNumberOfWorkers": 100,
    "sendDataOnlyOnChange": false,
    "security": {
      "type": "basic",
      "username": "user",
      "password": "password"
    }

When using MQTT v3, similar behavior can be achieved with:

  • cleanSession which must be false for the buffering to work
"broker": {
    "name": "Default Local Broker",
    "host": "127.0.0.1",
    "port": 1883,
    "clientId": "ThingsBoard_gateway",
    "version": 3,
    "cleanSession": false,
    "maxMessageNumberPerWorker": 10,
    "maxNumberOfWorkers": 100,
    "sendDataOnlyOnChange": false,
    "security": {
      "type": "basic",
      "username": "user",
      "password": "password"
    }

The above functionality is relevant for retained mqtt topics that include a timestamp such as:

{"temperature" : 23, "timestamp": 1721233307943}

Please note:
Although the above changes work when executing the gateway locally from source, they do not work when executing the gateway using docker. To my understanding, the issue is related to the mqtt connection of the gateway to thingsboard when publishing received messages.

in order to be able to receive retained messages
@CLAassistant
Copy link

CLAassistant commented Jul 17, 2024

CLA assistant check
All committers have signed the CLA.

@imbeacon imbeacon merged commit c9df1cb into thingsboard:master Jul 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants