0
votes

I have tried to establish a MQTT connection from the browser by using Kii Cloud service, but it failed.

Would you please any advise ?

[Event]

I have tried to establish a connection by using the end-point which I got from the Kii Cloud MQTT, but returned the following error.

※I use paho for MQTT client.

WebSocket connection to 'ws://[hostname which I got from Kil Cloud]:[port which I got from Kil Cloud]/mqtt' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET

[What I tried]

·I isolate the cause of the problem. (client--side or server--side)

→I run the sample code of paho, it was able to successfully connect to the broker(test.mosquitto.org:8080).

· Ping communication confirmation

→I can not ping the host I got from Kii Cloud.(I can ping the broker above)

[My code]

// 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]
});

[Environment]

Google Chrome: ver 49.0.2623.112 m

Client-side: paho

Server side: Kii Cloud

Thank you very much.

1

1 Answers

0
votes

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.