I'm using mqtt for rpc calls from Thingsboard. Basically request/response.
Every incoming topic is on this format:
msg.topic: "v1/devices/me/rpc/request/X"
and the response must update to:
msg.topic: "v1/devices/me/rpc/response/X"
Since this is universal and used many different places, I wanted to make a subflow of it to apply the topic once and for all. However, the subflow always stays disconnected! Normal mqtt out node works fine. I also tried moving broker config to subflow env, but still disconnected. Anyone have any good ideas here?
Example subflow:
[
{
"id": "f95ab49ee1f58ce2",
"type": "subflow",
"name": "tb mqtt response",
"info": "Automatically set response topic.\r\n\r\nInput:\r\nmsg.topic: \"v1/devices/me/rpc/request/15\"\r\n\r\nSend to TB mqtt response:\r\nmsg.topic: \"v1/devices/me/rpc/response/15\"\r\n",
"category": "network",
"in": [
{
"x": 120,
"y": 120,
"wires": [
{
"id": "724cba2270fcda01"
}
]
}
],
"out": [],
"env": [],
"meta": {},
"color": "#D8BFD8",
"icon": "node-red/bridge.svg",
"status": {
"x": 420,
"y": 200,
"wires": [
{
"id": "fbd497cf63e7ba7a",
"port": 0
}
]
}
},
{
"id": "9d81d107b4711d9d",
"type": "mqtt out",
"z": "f95ab49ee1f58ce2",
"name": "",
"topic": "",
"qos": "0",
"retain": "false",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "c032668b54c22629",
"x": 390,
"y": 120,
"wires": []
},
{
"id": "724cba2270fcda01",
"type": "function",
"z": "f95ab49ee1f58ce2",
"name": "topic response",
"func": "msg.topic = msg.topic.replace(\"/request/\", \"/response/\");\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 240,
"y": 120,
"wires": [
[
"9d81d107b4711d9d"
]
]
},
{
"id": "fbd497cf63e7ba7a",
"type": "status",
"z": "f95ab49ee1f58ce2",
"name": "",
"scope": [
"9d81d107b4711d9d"
],
"x": 320,
"y": 200,
"wires": [
[]
]
},
{
"id": "c032668b54c22629",
"type": "mqtt-broker",
"name": "Thingsboard",
"broker": " ",
"port": "",
"clientid": "",
"autoConnect": false,
"usetls": false,
"protocolVersion": "5",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]