为什么此MQTT客户端示例失败? [英] Why is this MQTT client example failing?

查看:1006
本文介绍了为什么此MQTT客户端示例失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在第一次使用Python和mosquitto库尝试MQTT.我的客户程序在下面.我正在尝试在 http://www.mqtt-dashboard.com/subscribe上使用公共演示MQTT服务器.但是,客户端代码失败,请参见下面的错误.有什么想法吗?

I am trying out MQTT for the first time using Python and the mosquitto library. My client program is below. I'm trying to use the public demo MQTT server at http://www.mqtt-dashboard.com/subscribe. However the client code is failing, see error below. Any ideas on what's going on?

#!/usr/bin/env python

import mosquitto

client = mosquitto.Mosquitto("fredtest", clean_session=True)
client.connect("broker.mqttdashboard.com", 1883)

client.publish("fred.test", "hello world", 1)

client.loop_forever()

错误消息:


C:\tmp>python mqttclient.py
Traceback (most recent call last):
  File "mqttclient.py", line 6, in 
    client.connect("broker.mqttdashboard.com", 1883)
  File "build\bdist.win-amd64\egg\mosquitto.py", line 582, in connect
  File "build\bdist.win-amd64\egg\mosquitto.py", line 657, in reconnect
  File "c:\python27\lib\socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 10060] A connection attempt failed because the connected pa
rty did not properly respond after a period of time, or established connection f
ailed because connected host has failed to respond

推荐答案

我目前无法将任何客户端连接到broker.mqttdashboard.com:1883-因此这可能与您的代码无关.

I'm not currently able to connect any client to broker.mqttdashboard.com:1883 - so this probably isn't an issue with your code.

要进行健全性检查,您是否尝试过连接到另一个代理,例如iot.eclipse.org:1883?

To sanity check, have you tried connected to another broker, such as iot.eclipse.org:1883 ?

这篇关于为什么此MQTT客户端示例失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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