0

我尝试使用Kii Cloud 服务从浏览器建立 MQTT 连接,但失败了。

请问您有什么建议吗?

[事件]

我尝试使用从 Kii Cloud MQTT 获得的端点建立连接,但返回以下错误。

※我将paho用于 MQTT 客户端。

WebSocket 连接到“ws://[我从 Kil Cloud 获得的主机名]:[我从 Kil Cloud 获得的端口]/mqtt”失败:WebSocket 握手期间出错:net::ERR_CONNECTION_RESET

[我试过的]

·我隔离了问题的原因。(客户端或服务器端)

→我运行了paho的示例代码,它能够成功连接到broker(test.mosquitto.org:8080)。

· Ping 通讯确认

→我无法 ping 我从 Kii Cloud 获得的主机。(我可以 ping 上面的代理)

[我的代码]

// Create a client instance
client = new Paho.MQTT.Client([hostname which I got from Kil Cloud], [port which I got from Kil Cloud], "clientId");

// set callback handlers
client.onConnectionLost = onConnectionLost;
client.onMessageArrived = onMessageArrived;

// connect the client
// client.connect({onSuccess:onConnect});
client.connect({
    onSuccess:onConnect,
    userName:[username which I got from Kil Cloud],
    password:[password which I got from Kil Cloud]
});

[环境]

谷歌浏览器:版本 49.0.2623.112 m

客户端:paho

服务器端:Kii Cloud

非常感谢。

4

1 回答 1

0

I guess it is caused by fixed string "clientID". Kii Cloud MQTT broker requires Client ID included in response of getting endpoint.

GET endpoint

Value of "mqttTopic" field is the client ID to be used in Kii Cloud MQTT broker. (It is unclear from the api document though.)

Value of "mqttTopic" field is also used as MQTT topic after you have succeeded to connect.

于 2017-02-03T02:17:38.843 回答