【问题标题】:mosquitto and ibm watson iot on raspberry pi Connection Refused覆盆子 pi 上的 mosquitto 和 ibm watson iot 连接被拒绝
【发布时间】:2017-05-11 14:05:39
【问题描述】:

我是物联网新手。我刚刚在我的 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"

这是我的配置文件:

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

【问题讨论】:

  • 所有 3 个程序(mosquitto、mosquitto_sub 和 mosquitto_pub)都使用相同的客户端 ID,这不起作用,每个连接都需要一个唯一的 ID
  • 您还可以在配置文件中发布您的密码。最好删除此问题并在没有密码的情况下重新发布,因为即使您编辑了问题,密码仍将保留在历史记录中
  • ps:删除设备并启动新设备更容易,因为它已经用于测试目的
  • 即使我吃午饭时,酒吧也只是不连接!
  • 在 ibm 终端端我得到 => 设备身份验证的用户 ID(令牌)无效:ClientID='d:pqci52:myfstream:gateway', ClientIP=41.***.**.* ** 2017 年 5 月 11 日 15:38:29 从 41.***.**.*** 关闭连接。该操作未经授权。过去 5 分钟内 2 次​​span>

标签: ibm-cloud mqtt iot mosquitto watson-iot


【解决方案1】:

我在日志中看到 Invalid userID (token) for device auth: ClientID='g:pqci52:myfstream:gateway' 而不是“token”尝试“use-token-auth” 这是配方中指定的您正在关注的示例。

【讨论】:

  • 我尝试了两种方法,即使我将它注入 cmd 以确保 sudo mosquitto_pub -d -h pqci52.messaging.internetofthings.ibmcloud.com -i 'g:pqci52:myfstream:gateway' -u use-token-auth -P Nr0CHkXNbn3o+WFeMW -t iot-2/type/myfstream/id/gateway/evt/status/fmt/raw -m "hello" 感谢您的帮助,我正在切换到 azure iothub 我已经在此浪费了足够的时间
  • 我今天早上检查了日志,发现 Token auth failed (Device/gateway not found in database): ClientID='g:pqci52:myfstream:gateway' 所以这个设备可能没有注册为一个网关。
  • 我很感激,Token auth succeeded: ClientID='d:pqci52:myfstream:gateway', ClientIP=************ 使用 mosquitto_pub -d -h pqci52.messaging.internetofthings.ibmcloud.com -i 'd:pqci52:myfstream:gateway' -u use-token-auth -P Nr0CHkXNbn3o+WFeMW -t iot-2/type/myfstream/id/gateway/evt/status/fmt/raw -m "hello"
  • 那么你现在尝试连接d作为设备成功了吗?
  • 是的,一切似乎都是正确的,除了我创建了两个设备,一个是树莓派订阅和另一个发布,它们连接正确,但我错了,我还在搞清楚:来自 ***** 的关闭连接******。主题无效:iot-2/type/myfstream/id/s2/evt/status 主题与允许的规则不匹配
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-16
  • 1970-01-01
  • 2017-05-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多