连接到Cloud-MQTT服务器时出现Paho-Mqtt错误RC-5

时间:2019-05-05 13:04:40

标签: mqtt paho

尝试连接到Cloud-mqtt代理时出错。

显示错误:

  

未连接错误:5

使用此代理程序时工作:

broker="iot.eclipse.org"

代码

import paho.mqtt.client as mqtt
import time
broker="m**.cloudmqtt.com"
port=1***1
username="***"
password="***"

def on_connect(client, userdata, flags, rc):
    if rc==0:
      print("connected ok")
    else:
        print("Not connected ERROR:",rc)

client = mqtt.Client('python_client_Rtb')  
client.username_pw_set(username, password)
client.on_connect=on_connect
client.connect(broker,port)  #connect to broker
client.loop_start()  #Start loop 

time.sleep(4) # Wait for connection setup to complete

print("loop started")

client.loop_stop()

实际输出:

Not connected ERROR: 5
Not connected ERROR: 5
Not connected ERROR: 5
loop started

预期输出:

connected ok

0 个答案:

没有答案