[help] the mqtt client, connection apollo written by python always reports an error Error 10054

first, apollo starts normally

clipboard.png

python code, very simple:

import time
import paho.mqtt.client as mqtt



def on_connect(client, userdata, flags, rc):
    print("Connected with result code " + str(rc))

if __name__ == "__main__":
    client = mqtt.Client()
    client.username_pw_set(username="admins",password="password")
    client.on_connect = on_connect

    client.connect("127.0.0.1", 61613, 60)
    client.loop_start()


    -sharpwhile True:
    time.sleep(1)
    client.publish(topic="message", payload="hello")

python2.7 compiler, error after running

Connected to pydev debugger (build 173.4674.37)
[Errno 10054] 
Exception in thread Thread-6 (most likely raised during interpreter shutdown):
Process finished with exit code 0

Mar.06,2021

python code needs an additional line

import time
import paho.mqtt.client as mqtt



def on_connect(client, userdata, flags, rc):
    print("Connected with result code " + str(rc))

if __name__ == "__main__":
    -sharpclient_id
    client_id = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
    client = mqtt.Client(client_id) -sharpClientId
    
    client.username_pw_set(username="admins",password="password")
    client.on_connect = on_connect

    client.connect("127.0.0.1", 61613, 60)
    client.loop_start()


    -sharpwhile True:
    time.sleep(1)
    client.publish(topic="message", payload="hello")
Menu