如何使用MQTT订阅Watson IoT设备事件? [英] How to subscribe a Watson IoT Device events using MQTT?

查看:85
本文介绍了如何使用MQTT订阅Watson IoT设备事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Paho和Python创建一个MQTT客户端,以与Watson IoT Platform中的设备连接.

I'm creating a MQTT client with Paho and Python to connect with a device in Watson IoT Platform.

我正确组装了经纪人:

<org>.messaging.internetofthings.ibmcloud.com:1883

和客户:

d:<org>:<type>:<deviceId>

以及该主题的发布值:

iot-2/evt/<eventName>/fmt/json Payload: {"db",56}

通过身份验证:用户名:use-token-auth密码:

With the authentication: username: use-token-auth Password:

一切正常.

但是我尝试订阅主题iot-2/type//id//evt//fmt/json

But I tried to subscribe the topic iot-2/type//id//evt//fmt/json

连接始终关闭,并且仪表板显示:

And the connection always closes, and the dashboard says:

关闭的连接.主题无效:iot-2/type/sound/id/ipt/evt/db/fmt/json主题与授权规则不匹配

Closed connection. The topic is not valid: iot-2/type/sound/id/ipt/evt/db/fmt/json The topic does not match an authorized rule

为什么这不起作用?谢谢

Why this don't work? Thank you

推荐答案

您无法使用"d :::" 的clientID订阅事件主题.您需要生成一个APIKey并使用"a:orgId:appId" 的clinetID订阅主题 iot-2/type/device_type/id/device_id/evt/event_id/fmt/format_string (iot-2/type/sound/id/ipt/evt/db/fmt/json)

You cannot subscribe to an events topic using using a clientID of "d:::". You need to generate an APIKey and use a clinetID of "a:orgId:appId" to subscribe to topic iot-2/type/device_type/id/device_id/evt/event_id/fmt/format_string (iot-2/type/sound/id/ipt/evt/db/fmt/json)

您可以用作参考: https://www.ibm.com/support/knowledgecenter/SSQP8H/iot/platform/applications/mqtt.html

这篇关于如何使用MQTT订阅Watson IoT设备事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆