Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/installationguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ These are the currently available MQTT configuration options:
order versions) or without the slash. See
[discussion](https://github.com/telefonicaid/iotagent-node-lib/issues/866).
- **clean**: this flag is by default true, set to false to receive QoS 1 and 2 messages while offline.
- **clientId**: string ID which identifies client in mqtt broker. By default is using a string composed by a fixed prefix
`iotajson_` and a random suffix, i.e. `iotajson_43bf8a3a`.
- **clientId**: string ID which identifies client in mqtt broker. By default is using a string composed by a fixed
prefix `iotajson_` and a random suffix, i.e. `iotajson_43bf8a3a`.

TLS options (i.e. **ca**, **cert**, **key**, **rejectUnauthorized**) are directly linked with the ones supported by the
[tls module of Node.js](https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options).
Expand All @@ -147,6 +147,7 @@ TLS options (i.e. **ca**, **cert**, **key**, **rejectUnauthorized**) are directl
The `config.amqp` section of the config file contains all the information needed to connect to the AMQP Broker from the
IoT Agent. The following attributes are accepted:

- **protocol**: protocol to use for connecting with the AMQP broker (`amqp`, `amqps`). The default is `amqp`
- **host**: Host where the AMQP Broker is located.
- **port**: Port where the AMQP Broker is listening
- **username**: username that identifies the IOTA against the AMQP broker (optional).
Expand Down Expand Up @@ -202,6 +203,7 @@ The ones relating specific JSON bindings are described in the following table.
| IOTA_MQTT_AVOID_LEADING_SLASH | mqtt.avoidLeadingSlash |
| IOTA_MQTT_CLEAN | mqtt.clean |
| IOTA_MQTT_CLIENT_ID | mqtt.clientId |
| IOTA_AMQP_PROTOCOL | amqp.protocol |
| IOTA_AMQP_HOST | amqp.host |
| IOTA_AMQP_PORT | amqp.port |
| IOTA_AMQP_USERNAME | amqp.username |
Expand Down
2 changes: 1 addition & 1 deletion lib/bindings/AMQPBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function start(callback) {
retryTime = constants.AMQP_DEFAULT_RETRY_TIME;
}

let uri = 'amqp://';
let uri = config.getConfig().amqp.protocol ? config.getConfig().amqp.protocol + `://` : 'amqp://';
if (config.getConfig().amqp) {
if (config.getConfig().amqp.username && config.getConfig().amqp.password) {
uri += config.getConfig().amqp.username + ':' + config.getConfig().amqp.password + '@';
Expand Down
6 changes: 6 additions & 0 deletions lib/configService.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function processEnvironmentVariables() {
'IOTA_MQTT_AVOID_LEADING_SLASH',
'IOTA_MQTT_CLEAN',
'IOTA_MQTT_CLIENT_ID',
'IOTA_AMQP_PROTOCOL',
'IOTA_AMQP_HOST',
'IOTA_AMQP_PORT',
'IOTA_AMQP_USERNAME',
Expand Down Expand Up @@ -105,6 +106,7 @@ function processEnvironmentVariables() {
'IOTA_MQTT_CLIENT_ID'
];
const amqpVariables = [
'IOTA_AMQP_PROTOCOL',
'IOTA_AMQP_HOST',
'IOTA_AMQP_PORT',
'IOTA_AMQP_USERNAME',
Expand Down Expand Up @@ -229,6 +231,10 @@ function processEnvironmentVariables() {
config.amqp = {};
}

if (process.env.IOTA_AMQP_PROTOCOL) {
config.amqp.protocol = process.env.IOTA_AMQP_PROTOCOL;
}

if (process.env.IOTA_AMQP_HOST) {
config.amqp.host = process.env.IOTA_AMQP_HOST;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
},
"keywords": [],
"dependencies": {
"amqplib": "~0.5.1",
"amqplib": "~0.10.3",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be also mentioned in the CHANGES_NEXT_RELEASE file. Something like this:

- Upgrade amqplib dependency from ~0.5.1 to ~0.10.3

"async": "2.6.4",
"body-parser": "1.20.0",
"dateformat": "3.0.3",
Expand Down
2 changes: 2 additions & 0 deletions test/unit/startup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ describe('Startup tests', function () {

describe('When the AMQP transport is started with environment variables', function () {
beforeEach(function () {
process.env.IOTA_AMQP_PROTOCOL = 'xxx';
process.env.IOTA_AMQP_HOST = 'localhost';
process.env.IOTA_AMQP_PORT = '9090';
process.env.IOTA_AMQP_USERNAME = 'useramqp';
Expand All @@ -98,6 +99,7 @@ describe('Startup tests', function () {
});

afterEach(function () {
delete process.env.IOTA_AMQP_PROTOCOL;
delete process.env.IOTA_AMQP_HOST;
delete process.env.IOTA_AMQP_PORT;
delete process.env.IOTA_AMQP_USERNAME;
Expand Down