node-red-contrib-amqp icon indicating copy to clipboard operation
node-red-contrib-amqp copied to clipboard

TypeError returned from debug node

Open pmclean1964 opened this issue 8 years ago • 6 comments

Getting a TypeError cannot read property "close" of null. I've tried multiple configurations using the default and the topology. Connecting to a RabbitMQ 3.4.4 server - which could be the issue. Will install a local instance to see if it persists.

pmclean1964 avatar Mar 29 '16 18:03 pmclean1964

@pmclean1964 +1 It isn't something related to the version, the same issue shows up on 3.6.5. Locally everything's ok. Something goes wrong when trying to connect to an external rabbitmq server. I have mine on the same network, running from a docker container. The node is showing up "connecting" but there's no connection at all.

samueledirito avatar Sep 22 '16 16:09 samueledirito

When are you getting the error? Because with all our configurations it works, both local, dockerized and external RabbitMQ servers have no connection problems. I need to have a little more info, so that I can reproduce the error.

abreits avatar Sep 23 '16 05:09 abreits

@abreits My external rabbitmq server is running on a Mac inside a docker container

samueledirito avatar Sep 23 '16 07:09 samueledirito

+1 on this... I have ActiveMQ running on one EC2 instance in AWS and Node-Red on another EC2 instance and they are in the same VPC (=no firewalls in between). As soon as I hit Deploy I get the following in the Log (one input and one output node):

0|node-red | 31 Jan 13:48:35 - [error] [amqp in:c5a2e3c7.ede5b] Error stopping node: TypeError: Cannot read property 'close' of null 0|node-red | 31 Jan 13:48:35 - [error] [amqp out:3464ab2d.a8007c] Error stopping node: TypeError: Cannot read property 'close' of null

QAnders avatar Jan 31 '18 13:01 QAnders

Anything?

jsteigerwalt-ss avatar Mar 30 '18 22:03 jsteigerwalt-ss

Looks to me like this happens when the connection does not complete, so the node.src value never gets set before the node is cleaned up. Here's my tweak.

            node.on("close", function () {
                if(node.src != null) {
                    node.src.close().then(function () {
                        node.server.freeConnection();
                        node.status({ fill: "red", shape: "ring", text: "disconnected" });
                    }).catch(function (err) {
                        node.server.freeConnection();
                        node.status({ fill: "red", shape: "dot", text: "disconnect error" });
                        node.error("AMQP " + node.amqpType + " node disconnect error: " + err.message);
                    });
                } else {
                    node.log("No need to close the node. There us no connection.");
                }
            });

Carl4 avatar Apr 20 '18 21:04 Carl4