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 Broker listen messages randomly #10812

Open
bastianfbr opened this issue Sep 13, 2024 · 7 comments
Open

MQTT Broker listen messages randomly #10812

bastianfbr opened this issue Sep 13, 2024 · 7 comments
Labels
in linear Issue or PR has been created in Linear for internal review

Comments

@bastianfbr
Copy link

bastianfbr commented Sep 13, 2024

Bug Description

After working a lot with n8n, i did some workflows with MQTT Triggers. Everything worked fine before but now worfklows are randomly triggers. I have a program which send messages to topics i listen. Messages are really sent but triggers are 1/100 triggered... What can i do ? Sounds like listeners aren't always listening.

In addition, I have a custom MQTT trigger in a workflow that avoid listening to retained messages and when i want to enable it, i have this error :
image

To Reproduce

Create several workflows with MQTT Triggers
Activate all and see them not triggered

Expected behavior

Just want that everything works as expected : should be triggered every time a message is listened

Operating System

Windows 11

n8n Version

1.57.0

Node.js Version

18

Database

PostgreSQL

Execution mode

main (default)

@Joffcom
Copy link
Member

Joffcom commented Sep 13, 2024

Hey @bastianfbr,

We have created an internal ticket to look into this which we will be tracking as "GHC-229"

@Joffcom Joffcom added the in linear Issue or PR has been created in Linear for internal review label Sep 13, 2024
@Joffcom
Copy link
Member

Joffcom commented Sep 16, 2024

Hey @bastianfbr,

Are you using the same mqtt topic or different topics and how many do you get up to before seeing the issue?

@bastianfbr
Copy link
Author

It was for the same topic

@Joffcom
Copy link
Member

Joffcom commented Sep 17, 2024

Hey @bastianfbr,

Typically I would expect one workflow and trigger per topic, Can you share a bit more info about what it is you are doing?

@tennox
Copy link
Contributor

tennox commented Oct 7, 2024

I am also having issues with my MQTT trigger.
First I also saw the max listeners warning in console, then figured I had a rather old n8n version and upgraded.
But still not working properly - it currently seems to trigger only on the first message, and only if I send it from cli laptop, but not from the MQTT sending node in n8n. Here's my workflow:

image

Nodes json:

{
  "meta": {
    "instanceId": "71cba87a424d172df0d2a5c5b532c51688885e58fc096bf267ef75427c03dd47"
  },
  "nodes": [
    {
      "parameters": {
        "topics": "zigbee2mqtt/dry-switch-heating",
        "options": {
          "jsonParseBody": false,
          "onlyMessage": false
        }
      },
      "id": "849978d3-619d-49b3-9905-9153b93a3bb7",
      "name": "on heater state",
      "type": "n8n-nodes-base.mqttTrigger",
      "typeVersion": 1,
      "position": [
        2140,
        1180
      ],
      "credentials": {
        "mqtt": {
          "id": "9sXSaJesebHLe5Sk",
          "name": "rose-MQTT"
        }
      }
    },
    {
      "parameters": {
        "topic": "zigbee2mqtt/dry-switch-heating/get/state",
        "sendInputData": false,
        "message": "=''",
        "options": {}
      },
      "id": "317cb6fa-98f3-484b-bbd7-b93136bff034",
      "name": "ask for state",
      "type": "n8n-nodes-base.mqtt",
      "typeVersion": 1,
      "position": [
        2140,
        1380
      ],
      "credentials": {
        "mqtt": {
          "id": "9sXSaJesebHLe5Sk",
          "name": "rose-MQTT"
        }
      }
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 1
            }
          ]
        }
      },
      "id": "d1ca9269-f4ab-4498-b53c-4129dc2c1965",
      "name": "Val-Check schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        1960,
        1380
      ]
    }
  ],
  "connections": {
    "Val-Check schedule": {
      "main": [
        [
          {
            "node": "ask for state",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {}
}

@tennox
Copy link
Contributor

tennox commented Oct 8, 2024

Over night it started to sometimes trigger on messages - and seemingly with some kind of pattern - but I don't know what to make of it:
(my current workflow is set up to send telegram on each received message - but somehow it only triggers sometimes and seemingly only on state switches, but also there only sometimes... 😕 )
image
image

@tennox
Copy link
Contributor

tennox commented Oct 8, 2024

Reproduced the 'sometimes'-ness with a very simple workflow:
image

{
  "meta": {
    "instanceId": "71cba87a424d172df0d2a5c5b532c51688885e58fc096bf267ef75427c03dd47"
  },
  "nodes": [
    {
      "parameters": {
        "topics": "zigbee2mqtt/dry-switch-heating",
        "options": {}
      },
      "id": "4263a094-2c47-4c28-acd5-95ad4ee48d34",
      "name": "MQTT Trigger",
      "type": "n8n-nodes-base.mqttTrigger",
      "typeVersion": 1,
      "position": [
        720,
        560
      ],
      "credentials": {
        "mqtt": {
          "id": "9sXSaJesebHLe5Sk",
          "name": "rose-MQTT"
        }
      }
    },
    {
      "parameters": {
        "chatId": "90964282",
        "text": "={{ $json.topic }}\n{{ $json.message }}",
        "additionalFields": {
          "appendAttribution": false,
          "parse_mode": "HTML"
        }
      },
      "id": "4017f48c-ae47-4aa1-98a5-d48a679f2b84",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        940,
        560
      ],
      "credentials": {
        "telegramApi": {
          "id": "y5bFEQpcxcfTzrqZ",
          "name": "Rosenhof Bot"
        }
      }
    }
  ],
  "connections": {
    "MQTT Trigger": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in linear Issue or PR has been created in Linear for internal review
Projects
None yet
Development

No branches or pull requests

3 participants