webstomp JS - 在尝试发送 rabbitmq 消息时获得非环回访问被拒绝

webstomp JS - getting a non-loopback access denied when trying to send rabbitmq message

我正在尝试使用包含以下行的 JS 脚本的 HTML 页面向 rabbitmq 发送消息:

var client = new StompJs.Client({
        brokerURL: 'ws://localhost:15674/ws',
        connectedHeaders: { login: 'my_rabbit_username', passcode: 'my_rabbit_password' },
        reconnectDelay: 5000,
        heartbeatIncoming: 4000,
        heartbeatOutgoing: 4000,
    });
client.activate();
function update_rabbit(){
        var rabbitName = document.getElementById("myRabbitLoc").value;
        console.log(rabbitName);
        client = new StompJs.Client({
            brokerURL: rabbitName,
            connectedHeaders: { login: 'my_rabbit_username', passcode: 'my_rabbit_password' },
            reconnectDelay: 5000,
            heartbeatIncoming: 4000,
            heartbeatOutgoing: 4000,
            });
        client.activate();
    }
 client.onStompError = function (frame) {
      // Will be invoked in case of error encountered at Broker
      // Bad login/passcode typically will cause an error
      // Complaint brokers will set `message` header with a brief message. Body may contain details.
      // Compliant brokers will terminate the connection after any error
      console.log('Broker reported error: ' + frame.headers['message']);
      console.log('Additional details: ' + frame.body);
    };

但是,如果我试图将“localhost”更改为本地网络中的任何其他 pc 名称,甚至将其更改为我自己的计算机名称,则消息将不会到达。我收到以下消息:

Broker reported error: Bad CONNECT
xxx.html:153 Additional details: non-loopback access denied

非常感谢任何关于如何完成这项工作的帮助

编辑: 更改为我的计算机名称时设法避免了错误报告,但消息仍然无法传递。 尝试将其更改为另一台网络计算机时,出现以下错误:

WebSocket connection to 'ws://xxx.xxx.net/15674/ws' failed: 
_createWebSocket @ client.ts:510
(anonymous) @ client.ts:432
fulfilled @ byte.ts:13

继续...

显然我的第一个连接代码有些错误。我使用了短语

connectedHeaders: { login: 'my_rabbit_username', passcode: 'my_rabbit_password' },

而我应该使用:

connectHeaders: { login: 'my_rabbit_username', passcode: 'my_rabbit_password' },

(connected 中没有'ed') 令人沮丧,但仅此而已:D