将Bluemix地理空间服务连接到Watson IoT Platform

时间:2016-08-25 10:45:36

标签: ibm-cloud geospatial iot

我已经在Bluemix中部署了Bluemix GeoSpatial入门应用程序。

在我想连接到Watson IoT Platform而不是演示MQTT服务器之前,它工作正常。

我将mqtt1.m2m4connectedlife.com更改为dzqml6.messaging.internetofthings.ibmcloud.com并将mqtt_uidmqtt_pw添加到起始参数jsonObject。

我在Watson IoT Platform Dashboard中创建了一个API密钥,并将这些值用于mqtt_uidmqtt_pw

然后在启动应用程序时,我在日志中收到“错误:连接被拒绝:未经授权”。

然后我还尝试了apiKey和apiToken形成mqtt_uidmqtt_pw的Watson IoT Platform环境变量,但仍然遇到了同样的错误。

我还尝试了clientid和notify / input主题的不同值,但没有成功。

我读了几篇其他类似错误的帖子,经过一段时间后解决,因为组织创建和分发到所有服务器之间存在延迟。

https://developer.ibm.com/answers/questions/163862/iot-cloud-error-not-authorized.html

所以我等了一天但仍然有同样的错误。

我还将自己添加为该组织的常任成员,如本文所述:Refused: not authorized error occurs with IBM IoT Foundation on Bluemix

我非常感谢你提供任何帮助!

2 个答案:

答案 0 :(得分:2)

启动器应用程序中有一部分Node.js代码直接订阅了通知主题。 auth错误是否来自该订阅尝试?如果是这样,您是否修改了代码的那部分以传递凭据?

以下是我所指的app.js中的代码行。

var clientId = 'geo-quickstart:' + port;
//create the MQTT client and subscribe
client = mqtt.createClient(1883,"mqtt1.m2m4connectedlife.com", { "clientId": clientId } );
console.log("Subscribing to topic: " + notify_topic_string + "\n");
client.subscribe(notify_topic_string);

如果您没有在createClient调用上传递凭据,请尝试将参数{username:“user”,password:“pass”}添加到参数列表中。

答案 1 :(得分:0)

使用API​​密钥建立MQTT连接时,请确保以下几点适用:

The MQTT client ID is in the format: a:orgId:appId
The MQTT user name is the API key: such as a-orgId-a84ps90Ajs
The MQTT password is the authentication token: such as MP$08VKz!8rXwnR-Q*

有关详细信息,请参阅documentation。如果您仍然遇到错误,请告知我们您的6个角色的物联网服务ID,我们可以检查日志以解决您获得授权错误的原因。