Rabbitmq 没有从 Paho js 客户端连接
Rabbitmq not connecting from Paho js client
这是我的 paho javascript 客户端代码
client = new Paho.MQTT.Client(host, Number(port), clientId);
client.onMessageArrived = onMessageArrived;
client.onMessageDelivered = onMessageDelivered;
client.onConnectionLost = onConnectionLost;
这里 port
8083
可以与其他代理一起使用,但不能与 Rabbitmq 一起使用。在文档中我找不到任何正确的端口号。
运行 sudo rabbitmqctl status
给出
[{rabbitmq_management,"RabbitMQ Management Console","3.6.2"},
{rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.6.2"},
{webmachine,"webmachine","1.10.3"},
{mochiweb,"MochiMedia Web Server","2.13.1"},
{rabbitmq_mqtt,"RabbitMQ MQTT Adapter","3.6.2"},
{listeners,[{clustering,25672,"::"},{amqp,5672,"::"},{mqtt,1883,"::"}]},
所以我也尝试使用端口 1883
。我正在关注 https://github.com/rabbitmq/rabbitmq-web-mqtt-examples/blob/master/priv/echo.html
我收到此错误:
WebSocket connection to 'ws://localhost:1883/mqtt' failed: Connection closed before receiving a handshake response
正如评论中所讨论的那样:
Rabbitmq 需要以下插件来支持基于 websockets 的 MQTT (http://github.com/rabbitmq/rabbitmq-web-mqtt)
这是我的 paho javascript 客户端代码
client = new Paho.MQTT.Client(host, Number(port), clientId);
client.onMessageArrived = onMessageArrived;
client.onMessageDelivered = onMessageDelivered;
client.onConnectionLost = onConnectionLost;
这里 port
8083
可以与其他代理一起使用,但不能与 Rabbitmq 一起使用。在文档中我找不到任何正确的端口号。
运行 sudo rabbitmqctl status
给出
[{rabbitmq_management,"RabbitMQ Management Console","3.6.2"},
{rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.6.2"},
{webmachine,"webmachine","1.10.3"},
{mochiweb,"MochiMedia Web Server","2.13.1"},
{rabbitmq_mqtt,"RabbitMQ MQTT Adapter","3.6.2"},
{listeners,[{clustering,25672,"::"},{amqp,5672,"::"},{mqtt,1883,"::"}]},
所以我也尝试使用端口 1883
。我正在关注 https://github.com/rabbitmq/rabbitmq-web-mqtt-examples/blob/master/priv/echo.html
我收到此错误:
WebSocket connection to 'ws://localhost:1883/mqtt' failed: Connection closed before receiving a handshake response
正如评论中所讨论的那样:
Rabbitmq 需要以下插件来支持基于 websockets 的 MQTT (http://github.com/rabbitmq/rabbitmq-web-mqtt)