I have an application that sends notifications via webhooks. I want to process this notification in Node-RED. So I used a "http in"-Node in Node-RED, configured it with method POST and entered /webhook-test as URL. For testing purposes I only wired a debug node to it. Then I used the test-feature in the other application and triggered a notification. The "http in"-Node receives this information which is good, but it fires mutliple times in a time frame of something like 2 minutes. I tested with a public available Webhook-Test-Service (https://webhook-test.com/), and there I get only one message as expected. What could be the reason that my http-in-Node fires multiple times? Of course I could overcome this with a delay-Node, but this is a dirty solution and does only fix the result but not the reason for this faulty behaviour.
Don't know.
Could you please provide the flow code, everything else is speculation without the flow code.
The http-in node definitely behaves as expected wherever I use the node.
The implication here is that something in your front-end code is triggering a 2nd post. The API test tool doesn't do it so it isn't a Node-RED issue, it has to be in your front-end.
Do you have a http response node configure with the http in node. If not your application may be resending due to not receiving a response.
This is the very simply flow
[
{
"id": "b5f0a4915adf75f1",
"type": "http in",
"z": "f5b3a313c1b32b9d",
"name": "Speedtest Webhook",
"url": "/speedtest-webhook",
"method": "post",
"upload": false,
"skipBodyParsing": false,
"swaggerDoc": "",
"x": 290,
"y": 240,
"wires": [
[
"597ac9e371782bf3"
]
]
},
{
"id": "457837a96cd791e8",
"type": "http request",
"z": "f5b3a313c1b32b9d",
"name": "",
"method": "POST",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://gotify.mydomain.com/message?token=mytoken",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 670,
"y": 240,
"wires": [
[]
]
},
{
"id": "597ac9e371782bf3",
"type": "function",
"z": "f5b3a313c1b32b9d",
"name": "function 97",
"func": "let pl = msg.payload.benchmarks.upload.passed;\nlet title = 'Speedtest Webhook Test';\nlet extras = '{\"client::display\":{\"contentType\":\"text/markdown\"}}';\nlet pljson = '{\"message\": \"# ' + pl + '\",\"priority\": 9,\"title\": \"' + title + '\",\"extras\": ' + extras + '}';\nmsg.payload = JSON.parse(pljson);\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 490,
"y": 240,
"wires": [
[
"457837a96cd791e8"
]
]
}
]
@TotallyInformation Why do you think it is a problem in the front-end? When I trigger the notification in the application und one system ((https://webhook-test.com/) behaves correct (only one message) and the other faulty (Node-RED, multiple messages), my guess would rather be that the problem is somewhere in my Node-RED flow ...
@E1cid Thanks! That was it! I had no http response node configured. After adding one, there is only one message finally. Sorry for this silly mistake ...
let pl = msg.payload.benchmarks.upload.passed;
let title = 'Speedtest Webhook Test';
let extras = '{"client::display":{"contentType":"text/markdown"}}';
let pljson = '{"message": "# ' + pl + '","priority": 9,"title": "' + title + '","extras": ' + extras + '}';
msg.payload = JSON.parse(pljson);
return msg;
Btw I had a quick look at your function node and you don't have to parse JSON strings:
let extras = { "client::display": { contentType: "text/markdown" } }
msg.payload = { message: "#" + pl, priority: 9, title: title, extras: extras }
should also work.
You are missing a HTTP-response node (every http-in should be paired with one)
Without this the client request will just be timed out and never get a response, which is likely to trigger it to try again
I suggest you wire a HTTP-response node directly to the HTTP-in node in parallel to the function node