我正在尝试使用Qpid Broker-J从浏览器中向正在运行的rhea.js实例发送AMQP 1.0消息。我能够使用node.js版本发送和接收消息。
我认为我必须添加/激活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
答案 0 :(得分:0)
好,我知道了。该插件已被激活,您只需要在代理管理Web界面或直接在配置中添加端口即可。对于正在寻找它的任何人,请在“代理”>“端口”>“添加端口”下查找。