I am using the node-amqp library to connect to a on-line stomp service, before I was using stomp-client, it was connected very successfully, but it doesn't support auto failure detection and reconnect, so I want to switch to node-amqp for more robust support.
var amqp = require('amqp');
var option = {
host: 'host'
, port: 61618
, login: 'my username'
, password: 'my password'
};
var implOpts = {
reconnect: true,
reconnectBackoffStrategy: 'exponential',
reconnectBackoffTime: 500
};
var connection = amqp.createConnection(option,implOpts);
connection.addListener('ready', function(){
console.log('ready connection ');
});
connection.on('error', function (error) {
console.log('Connection error' ,error);
});
connection.on('close', function () {
console.log('Connection close ');
});
the hostname, password, username and port are correct and working in stomp-client library example. However by working with the code above, I got a error saying connection error { message: 'Connection ended: possibly due to an authentication failure.' }. I looked through the code, didn't find any problem about my authentication or and code.
Here is the working code in stomp-client library.
var StompClient = require('stomp-client').StompClient;
var client = new StompClient('host', 61618, 'my username', 'my password', '1.0');
client.connect(function(sessionId) {
console.log('Trying to connect the real time service...');
});
could anybody tell me how to work with node-amqp to connect stomp service