MQTT.js
MQTT.js copied to clipboard
Failover Transport Errors
I am using Amazon MQ with failover, which is really multiple Apache MQ instances. Apache MQ has a failover transport ( https://activemq.apache.org/failover-transport-reference.html ) but it seems to me that mqtt.js doesn't support this feature. Would that be correct?
// NodeJS Example
const mqtt = require('mqtt');
const user = 'mqtt_user';
const pass = 'mqtt_pass';
const aws1 = `wss://${user}:${pass}@111111.mq.us-west-2.amazonaws.com:61619`;
const aws2 = `wss://${user}:${pass}@222222.mq.us-west-2.amazonaws.com:61619`;
const host = 'failover:(' + aws1 + ',' + aws2 + ')';
const options = { keepalive: 60, protocolId: 'MQTT', protocolVersion: 4, clean: true, reconnectPeriod: 1000 };
var client = mqtt.connect(host, options);
client.on( "connect", e => console.log('success') );
client.on( "error", e => console.log('failed\n', e) );
// Errors Returned
failed
Error: connect ECONNREFUSED xx.xx.xx.xx:61619
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: 'xx.xx.xx.xx',
port: 61619
}
// NodeJS Example
const mqtt = require('mqtt');
import { IClientOptions } from 'mqtt';
const user = 'mqtt_user';
const pass = 'mqtt_pass';
let options:IClientOptions = {
username: user,
password: pass,
clientId: uuid(),
servers: [
{
host: '//111111.mq.us-west-2.amazonaws.com',
port: 61619,
protocol: 'wss'
},
{
host: '//222222.mq.us-west-2.amazonaws.com',
port: 61619,
protocol: 'wss'
}
]
};
var client = mqtt.connect(options);
client.on( "connect", e => console.log('success') );
client.on( "error", e => console.log('failed\n', e) );
This is an automated message to let you know that this issue has gone 365 days without any activity. In order to ensure that we work on issues that still matter, this issue will be closed in 14 days.
If this issue is still important, you can simply comment with a "bump" to keep it open.
Thank you for your contribution.
This issue was automatically closed due to inactivity.