Qpid Broker-J Websocket 插件 AMQP 1.0

Qpid Broker-J Websocket Plugin AMQP 1.0

我正在尝试将 AMQP 1.0 消息发送到 运行 Qpid Broker-J instance from within the browser with rhea.js。我能够使用 node.js 版本发送和接收消息。

我想我必须 add/activate Websocket Plugin,我只是找不到关于在哪里以及如何做的任何文档。

到目前为止有人这样做过吗?

这是我的浏览器版本片段:

var server = "ws://localhost:5673";
var client = require("rhea");

client.options.username = "guest";
client.options.password = "guest";

client.on("message", function (context) {
  console.log(context.message.body);
});

var ws = client.websocket_connect(WebSocket);
var connection = client.connect({"connection_details":ws(server, ["binary", "AMQPWSB10", "amqp"]), "reconnect":false});
connection.open_receiver("examples");
var sender = connection.open_sender("examples");

function send(body) {
  sender.send({ body });
}

function sendMessage() {
  console.log("sendMessage");
  const message = document.getElementById("message").value;
  send(message);
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/rhea@1.0.2/dist/rhea.js"></script>
</head>
<body>
  <div>
    <input type="text" id="message" />
    <button type="button" onClick="sendMessage()" />send</button>
  </div>
</body>
</html>

使用这个脚本我收到 Error during Websocket handshake:

WebSocket connection to 'ws://localhost:5673/' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET

好的,我明白了。插件已经激活,您只需在经纪商管理网页界面或直接在配置中添加端口即可。对于任何正在寻找它的人,请在 Broker > Ports > Add Port 下查看。