Rabbitmq没有从Paho js客户端连接

时间:2016-05-26 05:09:19

标签: rabbitmq mqtt paho

这是我的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连接到' ws:// localhost:1883 / mqtt'失败:在收到握手响应之前关闭连接

1 个答案:

答案 0 :(得分:1)

在评论中被淘汰:

Rabbitmq需要以下插件来支持基于websockets的MQTT(see here for more info