Giter Club home page Giter Club logo

node-red-contrib-amqp's Introduction

Node-RED AMQP input and output nodes

node-red-contrib-amqp is a Node-RED package that connects directly to an AMQP server (e.g. RabbitMQ). It contains an input, an output and a configuration node to connect to AMQP exchanges or queues for Node-RED.

It uses the amqp-ts library for the AMQP connectivity.

Table of Contents

Installation

If you have installed Node-RED as a global node.js package (you use the command node-red anywhere to start it), you need to install node-red-contrib-amqp as a global package as well:

$[sudo] npm install -g node-red-contrib-amqp

If you have installed the .zip or cloned your own copy of Node-RED from github, you can install it as a normal npm package inside the Node-RED project directory:

<path/to/node-red>$ npm install node-red-contrib-amqp

Overview

The package contains the following Node-RED nodes:

input: amqp

Subscribes to an AMQP exchange or queue and reads messages from it. It outputs an object called msg containing the following fields:

  • msg.payload is a string or an object containing the content of the AMQP message.
  • msg.topic is a string containing the routing-key of the AMQP message.
  • msg.amqpMessage is an amqp-ts Message object containing the received message.sendto

If a topic is defined in the input node definition, that will be sent as msg.topic instead of the routing key.

In the settings you can only define the exchange type or queue and it's name. If you need to use an exchange or a queue with specific settings you can define the exchange or queue in the topology tab of the AMQP server configuration node. The input node will use the exchange or queue defined in the topology.

output: amqp

Delivers incoming the message payload to the specified exchange or queue. It expects an object called msg containing the following fields:

  • msg.payload: string or an object containing the content of the AMQP message to be sent.
  • msg.topic: string containing the routing-key of the AMQP message to be sent.
  • msg.options: object containing specific AMQP properties for the message to be sent, see the amqplib publish documentation for more information.

If a topic is defined in the output node definition, that will be sent as routing-key instead of the msg.topic. If the msg.payload field does not exist, the whole msg object will be sent.

In the settings you can only define the exchange type or queue and it's name. If you need to use an exchange or a queue with specific settings you can define the exchange or queue in the topology tab of the AMQP server configuration node. The output node will use the exchange or queue defined in the topology.

configuration: amqp-server

Defines the connection to the AMQP server. You can also define in more detail the exchanges and queues that are used in the input and output nodes and even define bindings between exchanges and queues in the topology tab.

topology tab

In the topology tab you can define the AMQP server exchange and queue topology (exchanges, queues and bindings). You define the topology in the JSON editor.

Topology configuration example:

{
    "exchanges": [
        {"name": "exchange1", "type": "direct", "options": {"durable": false}},
        {"name": "exchange2"}
    ],
    "queues": [
        {"name": "queue1", "options": {"messageTtl": 60000}},
        {"name": "queue2"}
    ],
    "bindings": [
        {"source": "exchange1", "queue": "queue1", "pattern": "debug", "args": {}},
        {"source": "exchange1", "exchange": "exchange2", "pattern": "error"},
        {"source": "exchange2", "queue": "queue2"}
    ]
};

Known issues

  • Entering invalid credentials (username/password) in the AMQP configuration node can cause node-red to malfunction
  • Package library 'amqlib' is outdated, requiring breaking changes
  • Build libraries 'typescript' and 'gulp-typescript' are outdated, requiring breaking changes

What's new

version 1.0.1

  • bugfix, introduced by v1.0.0: Connections would not establish on startup, but would after a deploy.

version 1.0.0

  • Use Credentials/Credentials fields descriptions changed to 'Use Local CA File' and 'CA File Location' with accompanying functional change:

  • The 'CA File Location' field no longer specifies an explicit certificate, but a local disk location to load

    This is important as many certs have binary data in them, which is incompatible with a copy/paste in NodeRed GUI.

  • When a custom CA file location is not specified, an attempt is made to load the default system CA certificate

    Currently default supports ubuntu and alpine.

    Other distros should contribute their locations to this project as desired, but could still manually enter the location to be able to enjoy the functionality. If you were previously using non-system-default cert text in an AMQP node, this update would be a breaking change.

  • Some small GUI quality of life improvement to disable/enable TLS related fields when TLS enabled checkbox is exercised

  • bugfix, 'Enable secure connection' + 'Use Local CA File' checkbox drives whether to use the 'CA File Location' field;

    before it would use the field even when the checkbox was unchecked

  • Library dependencies upgraded to address all non-low vulnerabilities. Remaining low vulnerability will require upgrading typescript and gulp-typescript, along with breaking updates.

version 0.4.5

  • Unknown, just documenting this version existed. It is available in NPM, but not documented here

version 0.4.4

  • bugfix, topology editor not visible in amqp-server config node

version 0.4.3

  • bugfix, fixed routingkey not working in configuration/definition (thanks to exogenesick)

version 0.4.0

  • major refactor, made preparations for better testable code:
    • javascript source code has been translated to typescript
    • gulp build system added

version 0.3.0

  • connection to AMQP server now only established when amqp input and/or AMQP output nodes exist
  • major refactor and code cleanup
  • fixed errors in readme

version 0.2.0

  • fixed user credentials not working
  • improved readme

version 0.1.0

  • initial release

Roadmap

  • Resume active maintenance of the project into 2019!
  • I would like to see version 1.1.0 aim to accomplish:
  • All dependencies upgraded to current
  • Test suite in place

node-red-contrib-amqp's People

Contributors

abreits avatar cfsghost avatar exogenesick avatar mikesmithurbangro avatar rossigee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-red-contrib-amqp's Issues

Cannot read property 'forEach' of undefined

When I try to install the node-red-contrib-amqp, I get the error as

Cannot read property 'forEach' of undefined

So, I cannot use the nodes anymore.

Node-RED version: v1.0.3
Node.js version: v12.14.0

Trying to connect to CloudAMQP

So I am able to connect using port 5672 but can't using the secured 5671 port. I receive the error "unable to get local issuer certificate". CloudAMQP is a hosted RabbitMQ environment that doesn't use certificates but rather username and password. Below is a blurb about the error I am receiving from the CloudAMQP site.

"Using TLS but no client certificate is provided! If RabbitMQ is configured to verify peer certificate, connection upgrade will fail!"
You don't have to worry about this error. We don't recommend client certs at the moment, it's hard to setup and don't necessarily increase the security. We use the username/password as authentication and authorization, just like any HTTPS protected website, the traffic is still fully encrypted and protected from MITM-attacks etc.

Thanks for any help!

Control Message Acknowledgements

Hi Ab,

is there any posibility to control the Acknowledgement of the Message in the Flow?
It seemed to me that before sending the Msg to the output auf the Node the Msg will be acknowledge.

Regards
oliver

way to acknowledge a amqpMessage

Hi,
I have been trying to acknowledge amqpMessage manually after setting noack:false in
node.src.activateConsumer(Consume, { noAck: false }).then(function () {

when i try to call amqpMessage.ack(false); it gives error saying "write callback called multiple times",
also i read in amqp-ts document , the ideal way to make this work is using the following code
queue.activateConsumer((msg) => { //process the msg msg.ack(); });

How do i get the queue context in my function node where i am manually trying to acknowledge the message.

manually nack or reject a message

Hello,

There is a node input with which you can manually acknowledge a message, is there a way to also reject/nack that message or is that a missing feature?

Thanks

amqp.html missiing after install with Manage Palette

node-red 1.1.0

Manage Palette - install node-red-contrib-amqp
install successful
?no amqp nodes
check Installed tab in Manage Palette
Error: /home/vcap/app/.node-red/node_modules/node-red-contrib-amqp/lib/amqp.html does not exist

TypeError returned from debug node

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.

amqplib not supported

Hi

I see this issue installing ampq

โฏ docker exec -it mynodered /bin/bash
bash-5.0$ npm install node-red-contrib-tado node-red-contrib-amqp
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":">=0.8 <6 || ^6"} (current: {"node":"10.19.0","npm":"6.13.4"})
npm WARN notsup Not compatible with your version of node/npm: [email protected]

seems like amqplib is a bit behind?

Connecting but no messages from topic exchange

Node is connecting successfully but no messages flowing. I've tested my Rabbit config with the following Node code (sample from RabbitMQ) and this receives messages ok. Code run using wildcard # as topic argument.

var amqp = require('amqplib/callback_api');
var args = process.argv.slice(2);

if (args.length == 0) {
console.log("Usage: node robolistener.js [topic]");
process.exit(1);
}
amqp.connect('amqp://rabbitmqserver', function(err, conn) {
conn.createChannel(function(err, ch) {
var ex = 'events.X.EVENTS';
ch.assertExchange(ex, 'topic', );
ch.assertQueue('', {exclusive: true}, function(err, q) {
console.log(' [*] Waiting for messages. To exit press CTRL+C');
args.forEach(function(key) {
ch.bindQueue(q.queue, ex, key);
});
ch.consume(q.queue, function(msg) {
console.log(" [x] %s:'%s'", msg.fields.routingKey, msg.content.toString());
}, {noAck: true});
});
});
});

Using this configuration in node-red with amqp node connects but does not pass any messages to debug node. Config is as follows:

source: rabbitmqserver:5672
read from: topic exchange
events.X.EVENTS
topic: #

node-red crashes when two or more branches are configured after amqp in

I am using amqp node. It works ok (both amqp in and out).
The error happens when create more than one branch after amqp in.

When I do that, node-red simply crashes dumping the following text:

16 Feb 08:18:23 - [info] Starting flows
16 Feb 08:18:23 - [info] Started flows
16 Feb 08:18:23 - [info] [amqp-server:6721fcee.728ce4] Initializing in-clear AMQP connection
16 Feb 08:18:23 - [info] [amqp-server:6721fcee.728ce4] Connected to AMQP server amqp://localhost:5672?heartbeat=30
FATAL ERROR: v8::Object::SetInternalField() Internal field out of bounds
1: 0x9dab80 node::Abort() [node-red]
2: 0x9dbd36 node::OnFatalError(char const*, char const*) [node-red]
3: 0xb3b22a v8::Utils::ReportApiFailure(char const*, char const*) [node-red]
4: 0xebd6cc v8::internal::Object::SetPropertyWithAccessor(v8::internal::LookupIterator*, v8::internal::Handlev8::internal::Object, v8::Maybev8::internal::ShouldThrow) [node-red]
5: 0xedae0b v8::internal::Object::SetPropertyInternal(v8::internal::LookupIterator*, v8::internal::Handlev8::internal::Object, v8::Maybev8::internal::ShouldThrow, v8::internal::StoreOrigin, bool*) [node-red]
6: 0xedaf73 v8::internal::Object::SetProperty(v8::internal::LookupIterator*, v8::internal::Handlev8::internal::Object, v8::internal::StoreOrigin, v8::Maybev8::internal::ShouldThrow) [node-red]
7: 0x100b224 v8::internal::Runtime::SetObjectProperty(v8::internal::Isolate*, v8::internal::Handlev8::internal::Object, v8::internal::Handlev8::internal::Object, v8::internal::Handlev8::internal::Object, v8::internal::StoreOrigin, v8::Maybev8::internal::ShouldThrow) [node-red]
8: 0x100c94a v8::internal::Runtime_SetKeyedProperty(int, unsigned long*, v8::internal::Isolate*) [node-red]
9: 0x1376519 [node-red]
Aborted (core dumped)

Environment:
Ubuntu 18.04
Node 12.15.0
npm 6.13.4
node-red 1.0.3
node-red-contrib-amqp 1.0.2

Server configuration as global and not as local

Hi,

Is there a way, that I can save the amqp server configuration global so I just can pickit up on every workflow?

Current the configuration is saved in the local workspace of the workflow. As I do have a lot of workflows I like to have just one central configuration space where I can easy switch the configuration between integration or production environment.

My wish would be a possibility to save it local (as default as you have it today) and an optional save it global checkbox.

Default Exchange support

I like to set no exchange address and like to use the default exchange support with an empty string but the UI does require always an entry in the exchange name.
Thank you

SSL Configuration Options not working

I have a RabbitMQ server configured to run over SSL that I am trying to connect to and it is not working.
The RabbitMQ server is currently configured to accept any certificate and it works perfectly well with regular NodeJS using amqplib package.

But I just can't get SSL working for this Node-RED implementation. I have tried all kind of options and the closest I get to success is the error message "AMQP input node connect error: unable to verify the first certificate". Copy/pasted certificate (and tried several different ones) into the credentials.

My RabbitMQ server logs says the following:
2019-01-24 20:11:01.987 [debug] <0.629.0> accepting AMQP connection <0.629.0> (127.0.0.1:42118 -> 127.0.0.1:5671)
2019-01-24 20:11:01.987 [debug] <0.629.0> closing AMQP connection <0.629.0> (127.0.0.1:42118 -> 127.0.0.1:5671): connection_closed_with_no_data_received

Any possibility of some guidance if I am doing something wrong?

AMQP output node connect error: Cannot read property 'toLowerCase' of undefined

Hi
I tried to use the amqp node on my node-RED install but I had some troubles. This error happened, I could not connect :

AMQP output node connect error: Cannot read property 'toLowerCase' of undefined

So I edited the amqp.js file and removed this line to make the node work :

osDistroLowerCase = result.dist.toLowerCase();
I'm using Windows 10, node.js v8.16.1 and npm v6.4.1.
Is it a bug or something ? I don't know a lot about javascript...

I made it work removing the line and typing "windows" as osDistroLowerCase value but I'm pretty shure that it's not the best way to deal with this issue ๐Ÿ˜†

Anyway, I hope it can be usefull

Unsupported engine for [email protected]

Error when trying to add npm package to latest version of node-red

sudo npm install -g node-red-contrib-amqp
npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":">=0.8 <6 || ^6"} (current: {"node":"12.19.1","npm":"6.14.8"})
npm WARN notsup Not compatible with your version of node/npm: [email protected]
$ node --version
v12.19.1
$ npm --version
6.14.8

make it as both I/O node

As of now, my ampq give me a response back. so we need to do something to catch that response and show it.

Assertion `(object-> InternalFieldCount()) > (0)' failed.

Hi,
I have a flow having select and update operations with postgres database using the node (node-red-contrib-postgres). This is working properly when I manually give the value using Inject but when I get the same message from rabbitmq server (both persistent&non-persistent), getting the below response and my server application/node-red server is going down.

C:\Program Files\nodejs\node.exe: c:\ws\src\util-inl.h:243: Assertion `(object->
InternalFieldCount()) > (0)' failed.

When i send the amqp receiver node directly to debug node without connection to other nodes it is receiving the messages properly. I tried by connecting to further nodes in my flow and each time it is stopping at different node (but mostly at postgres node) with the above error. No issues faced when tried without amqp receiver.
Please help.

node-red version: "0.18.7"
node-red-contrib-amqp version: "0.4.4"
node-red-contrib-postgres version: "0.6.1"
rabbitmq_server-3.6.10 (local)
Erlang 20.0

Do these nodes work in the latest version of node-red?

When I used "amqp input" node, I got errors and could not make a connection to rabbitmq.
I got an error message like this, "AMQP input node connect error: Cannot assign to read only property 'toLowerCase' of undefined."
Node version: v10.16.3
NPM version: 6.9.0
Node-red version: v1.0.2
Do these nodes work in the latest version of node-red?

[AmqpOut node] Publish messages with routing key never works through node definition "Routing key" option

In AmqpOut node publishing messages with specified routing key now works only through msg.topic. Never works with node configuration dialog/definition which is explained here https://github.com/abreits/node-red-contrib-amqp#output-amqp.

It's because of mistake located here: https://github.com/abreits/node-red-contrib-amqp/blob/master/src/nodejs/amqp.ts#L98

Should be:

node.topic = n.routingkey;

instead of:

node.topic = n.topic;

When I debug node definition (AmqpOut node n parameter) it shows me this:

{ id: 'bb1c6ed3.44e39',
  type: 'amqp out',
  z: '1dfb0672.e204fa',
  name: 'producer',
  routingkey: 'a.b.c',
  iotype: '3',
  ioname: 'requests',
  server: '6100766a.9eff88',
  x: 586.1817512512207,
  y: 336.9090938568115,
  wires: [] }

Above debug object contains routingkey property which is proper Routing key option of node definition. Property topic not exists in this object.

Pull request here #2

Cannot assign to read only property 'writeQueueSize' of object '#<TCP>' module=amqp-ts

Hello
Thank you for this excellent node.
Whenever connecting more than 1 nodes to the output of AMQP Input node the subject error is thrown.

Here is a more descriptive output from nodered
nodered_1 | error: Queue.onMessage consumer function returned error: Cannot assign to read only property 'writeQueueSize' of object '#' module=amqp-ts

Here is some more when connected differently
nodered_1 | 11 Jun 00:05:27 - [error] [switch:d903e45c.b0b468] TypeError: Cannot assign to read only property 'writeQueueSize' of object '#'
nodered_1 | at _clone (/usr/src/node-red/node_modules/clone/clone.js:162:16)
nodered_1 | at _clone (/usr/src/node-red/node_modules/clone/clone.js:162:18)
nodered_1 | at _clone (/usr/src/node-red/node_modules/clone/clone.js:162:18)
nodered_1 | at _clone (/usr/src/node-red/node_modules/clone/clone.js:162:18)
nodered_1 | at _clone (/usr/src/node-red/node_modules/clone/clone.js:162:18)
nodered_1 | at _clone (/usr/src/node-red/node_modules/clone/clone.js:162:18)
nodered_1 | at clone (/usr/src/node-red/node_modules/clone/clone.js:202:10)
nodered_1 | at Object.cloneMessage (/usr/src/node-red/node_modules/@node-red/util/lib/util.js:90:13)
nodered_1 | at SwitchNode.Node.send (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:199:61)
nodered_1 | at applyRules (/usr/src/node-red/node_modules/@node-red/nodes/core/logic/10-switch.js:441:42)
nodered_1 | at applyRule (/usr/src/node-red/node_modules/@node-red/nodes/core/logic/10-switch.js:224:17)
nodered_1 | at getV2 (/usr/src/node-red/node_modules/@node-red/nodes/core/logic/10-switch.js:199:17)
nodered_1 | at getV2 (/usr/src/node-red/node_modules/@node-red/nodes/core/logic/10-switch.js:168:13)
nodered_1 | at getV1 (/usr/src/node-red/node_modules/@node-red/nodes/core/logic/10-switch.js:181:13)
nodered_1 | at /usr/src/node-red/node_modules/@node-red/nodes/core/logic/10-switch.js:141:21
nodered_1 | at Object.evaluateNodeProperty (/usr/src/node-red/node_modules/@node-red/util/lib/util.js:540:9)

Thanks

amqp nodes stuck 'connecting'

Set up a fresh NodeRed flow. Add a trigger and an 'amqp-out' node and link them up. Install a fresh RabbitMQ install (localhost port 5672, guest/guest login). Configure 'amqp-out' node. Trigger flow.

Expected result: Either a successful connection, or an error.
Actual result: Node gets stuck at 'connecting'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.