简体   繁体   English

将Bluemix地理空间服务连接到Watson IoT Platform的未授权错误

[英]Not authorized error connecting Bluemix geospatial service to Watson IoT Platform

I have deployed the Bluemix GeoSpatial starter application in Bluemix. 我已经在Bluemix中部署了Bluemix GeoSpatial入门应用程序。

It works fine until I want to connect to the Watson IoT Platform instead of the demo MQTT server. 在我想连接到Watson IoT Platform而不是演示MQTT服务器之前,它可以正常工作。

I changed mqtt1.m2m4connectedlife.com to dzqml6.messaging.internetofthings.ibmcloud.com and added mqtt_uid and mqtt_pw to the start parameters jsonObject. 我将mqtt1.m2m4connectedlife.com更改为dzqml6.messaging.internetofthings.ibmcloud.com ,并将mqtt_uidmqtt_pw添加到起始参数jsonObject中。

I created an API key in the Watson IoT Platform Dashboard and used these values for mqtt_uid and mqtt_pw . 我在Watson IoT Platform仪表板中创建了一个API密钥,并将这些值用于mqtt_uidmqtt_pw

Then I get an "Error: Connection refused: Not authorized" in the log when starting the application. 然后,在启动应用程序时,日志中显示“错误:连接被拒绝:未经授权”。

Then I also tried the apiKey and apiToken form the Watson IoT Platform environment variables for mqtt_uid and mqtt_pw but still got the same error. 然后,我还尝试使用Watson IoT Platform环境变量的mqtt_uidmqtt_pw来设置mqtt_uidmqtt_pw但仍然遇到相同的错误。

I also tried different values for clientid and notify/input topics but without success. 我也尝试为clientid和notify / input主题使用不同的值,但没有成功。

I read a couple of other posts with similar errors that were resolved after some time because of a delay between when an organization is created and is distributed to all servers. 我读了其他几篇类似错误的文章,由于创建组织和将其分发到所有服务器之间存在延迟,一段时间后解决了这些错误。

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

So I waited a day but still have the same error. 所以我等了一天,但仍然有同样的错误。

I also added myself as a permanent member to the organization as suggested in this post: Refused: not authorized error occurs with IBM IoT Foundation on Bluemix 我还按照帖子中的建议将自己添加为组织的永久成员: 拒绝:Bluemix上的IBM IoT Foundation发生未授权的错误

I would be very gratefull for any assistance on this! 对于这个方面的任何帮助,我将不胜感激!

There's a part of the Node.js code in the starter app that directly subscribes to the notify topic. 入门应用程序中的Node.js代码中有一部分直接订阅了notify主题。 Is the auth error coming from that subscription attempt? 身份验证错误是否来自该订阅尝试? If so, did you modify that part of the code to pass credentials? 如果是这样,您是否修改了代码的那部分以通过凭据?

Here are the lines of code in the app.js that I'm referring to. 这是我指的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);

If you aren't passing the credentials on the createClient call, try adding a parameter {username: "user", password: "pass"} to the list of arguments. 如果您没有在createClient调用中传递凭据,请尝试将参数{username:“ user”,password:“ pass”}添加到参数列表中。

When you make an MQTT connection by using an API key, ensure that the following points apply: 使用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*

See the documentation for more details. 有关更多详细信息,请参见文档 If you still experience errors, let us know your 6 character org ID for the IoT service and we can check logs to troubleshoot why you are getting authorization error. 如果您仍然遇到错误,请让我们知道您的IoT服务的6个字符的组织ID,我们可以检查日志以对您为什么遇到授权错误进行故障排除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM