Hey,
I'm working on a node, which is listening on an endpoint which is set up using a RED.httpNode.post call. I'm having an issue where after deploy the node stops outputting messages, but I am getting a response on the http call.
I also find that removing the node and deploying will still get responses from the node via HTTP (where the HTTP-In node will stop responding if it's deleted and deployed).
My suspcion is that it's the HTTP Post from first load is being kept open, and we need to close this HTTP Post listener on deploy before re-opening it again.
This code on HTTP In seems to clean itself up, but when I run it on my node, _router.routes is empty
this.on("close",function() {
var node = this;
RED.httpNode._router.stack.forEach(function(route,i,routes) {
if (route.route && route.route.path === node.url && route.route.methods[node.method]) {
routes.splice(i,1);
}
});
});
What am I doing wrong? There's seems to be no documentation on how to use RED.httpAdmin.post
This is my code:
var obj = RED.httpAdmin.post(('/webhook/' + node.id), function(req, res){ WebhookCallback(req, res); } );
this.on('close', function() {
console.log("close");
// tidy up any state
obj = undefined;
var node = this;
RED.httpNode._router.stack.forEach(function(route,i,routes) {
routes.splice(i,1);
});
});
I've tried in this example just removing everything for debugging, but it still persists