我是物联网的新手。我刚刚在我的rpi上安装了mosquitto,并使用本教程在Watson IoT Platform中注册了我的设备和网关:https://developer.ibm.com/recipes/tutorials/using-mosquitto-as-a-gateway-for-watson-iot/
Mosquitto工作良好的本地模式。但是,我在使用这些命令订阅/发布时遇到问题:
mosquitto_sub -d -h pxci52.messaging.internetofthings.ibmcloud.com -i 'g:pxci52:myfstream:gateway' -t iot-2/type/myfstream/id/gateway/evt/status/fmt/raw
和
sudo mosquitto_pub -d -h pxci52.messaging.internetofthings.ibmcloud.com -i 'g:pxci52:myfstream:gateway' -t iot-2/type/myfstream/id/gateway/evt/status/fmt/raw -m "hello"
这是我的conf文件:
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest topic
log_type error
log_type warning
log_type notice
log_type information
connection_messages true
log_timestamp true
include_dir /etc/mosquitto/conf.d
connection bridge-to-watsoniot
address pxci52.messaging.internetofthings.ibmcloud.com:1883
cleansession true
try_private false
bridge_attempt_unsubscribe false
notifications false
notification_topic iot-2/type/myfstream/id/gateway/evt/status/fmt/raw
remote_username token
remote_password xxxxxx
remote_clientid g:pxci52:myfstream:gateway
notifications true
topic iot-2/type/+/id/+/cmd/+/fmt/+ in iot-2/type/+/id/+/cmd/+/fmt/+
topic iot-2/type/+/id/+/evt/+/fmt/+ out iot-2/type/+/id/+/evt/+/fmt/+
connection_messages true
答案 0 :(得分:0)
我在日志中看到设备身份验证的无效用户ID(令牌):ClientID =' g:pqci52:myfstream:gateway'而不只是"令牌"尝试" use-token-auth"这就是您所遵循的配方示例中指定的内容。