【发布时间】:2017-10-07 23:25:48
【问题描述】:
背景
尝试使用 AMQP 1.0 协议通过 amqp10 连接到我的 Apache ActiveMQ 代理。我正在使用以下代码(改编自 README 中的原始示例):
const AMQPClient = require("amqp10").Client;
const Promise = require("bluebird");
//Fix from: https://github.com/noodlefrenzy/node-amqp10/issues/241
const activeMQPolicy = require("amqp10").Policy;
const client = new AMQPClient(activeMQPolicy.ActiveMQ);
const setUp = () => {
return Promise.all([
client.createReceiver("amq.topic"),
client.createSender("amq.topic")
]);
};
client.connect("amqp://localhost")
.then(setUp)
.spread(function (receiver, sender) {
receiver.on("errorReceived", function (err) {
if (err) {
console.log(`failed with error: ${err}`);
return;
}
receiver.on("message", message => console.log(`Rx message: ${message.body}`));
return sender.send({ key: "Value" });
});
})
.error( err => console.log("error: ", err));
错误
执行失败并出现以下应用程序错误:
工作区/activemq/node_modules/amqp10/lib/frames.js:64 stream.write(缓冲区,回调); ^
TypeError:无法读取 null 的属性“写入” 在 Object.frames.writeFrame (/home/pedro/Workspace/activemq/node_modules/amqp10/lib/frames.js:64:9) 在 Connection.sendFrame (/home/pedro/Workspace/activemq/node_modules/amqp10/lib/connection.js:329:10) 在 Connection._sendCloseFrame (/home/pedro/Workspace/activemq/node_modules/amqp10/lib/connection.js:491:8) 在 Connection._receiveAny (/home/pedro/Workspace/activemq/node_modules/amqp10/lib/connection.js:413:12) 在 Connection._receiveData (/home/pedro/Workspace/activemq/node_modules/amqp10/lib/connection.js:358:8) 在 NetTransport。 (/home/pedro/Workspace/activemq/node_modules/amqp10/lib/connection.js:516:38) 在 emitOne (events.js:96:13) 在 NetTransport.emit (events.js:191:7) 在套接字。 (/home/pedro/Workspace/activemq/node_modules/amqp10/lib/transport/net_transport.js:26:49) 在 emitOne (events.js:96:13) 在 Socket.emit (events.js:191:7) 在 readableAddChunk (_stream_readable.js:178:18) 在 Socket.Readable.push (_stream_readable.js:136:10) 在 TCP.onread (net.js:560:20)
虽然 ActiveMQ 拒绝请求并显示以下消息:
警告 |来自非 AMQP v1.0 客户端的连接尝试。 AMQP,0,1,0,0 警告 |传输连接到:tcp://127.0.0.1:53188 失败:org.apache.activemq.transport.amqp.AmqpProtocolException:尝试使用不受支持的 AMQP 来自客户端的连接
我尝试了什么
我尝试实施此问题中描述的修复:
但它也没有工作。还尝试在 url 中指定端口 5672,但没有成功。
问题
此时我很确定应用程序写入失败,因为 ActiveMQ 将请求视为无效而拒绝。
- 关于如何解决此问题的任何想法?
【问题讨论】: