【问题标题】:Qpid Broker-J Websocket Plugin AMQP 1.0Qpid Broker-J Websocket 插件 AMQP 1.0
【发布时间】:2019-08-15 22:31:42
【问题描述】:

我正在尝试使用 rhea.js 从浏览器内将 AMQP 1.0 消息发送到正在运行的 Qpid Broker-J 实例。我能够使用 node.js 版本发送和接收消息。

我想我必须添加/激活Websocket Plugin,我只是找不到任何关于在哪里以及如何执行此操作的文档。

到目前为止,有人做过吗?

这是我的浏览器版本 sn-p:

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

【问题讨论】:

    标签: javascript websocket amqp messagebroker qpid


    【解决方案1】:

    好的,我想通了。该插件已激活,您只需在代理管理 Web 界面中添加端口,或直接在配置中添加。对于正在寻找它的任何人,请查看 Broker > Ports > Add Port。

    【讨论】:

      猜你喜欢
      • 2018-10-08
      • 2018-02-12
      • 1970-01-01
      • 2019-06-18
      • 2013-10-10
      • 2013-07-25
      • 2016-11-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多