Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » attribute _on_pre_connect error
attribute _on_pre_connect error [message #1859844] Thu, 29 June 2023 21:30
Luuc BENECHET is currently offline Luuc BENECHETFriend
Messages: 1
Registered: June 2023
Junior Member
I make a fresh installation and run the example code:
import paho.mqtt.client as mqtt
import ssl

# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
    print("Connected with result code "+str(rc))
    # Subscribing in on_connect() means that if we lose the connection and
    # reconnect then subscriptions will be renewed.
    client.subscribe("$SYS/#")

# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
    print(msg.topic+" "+str(msg.payload))

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.tls_set()
client.connect("mqtt.eclipseprojects.io", 8883, 60)

# Blocking call that processes network traffic, dispatches callbacks and
# handles reconnecting.
# Other loop*() functions are available that give a threaded interface and a
# manual interface.
client.loop_forever()


I have an error:

Traceback (most recent call last):
  File "mqtt.py", line 19, in <module>
    client.connect("mqtt.eclipseprojects.io", 8883, 60)
  File "/usr/local/lib/python3.7/dist-packages/paho_mqtt-1.6.1-py3.7.egg/paho/mqtt/client.py", line 914, in connect
    return self.reconnect()
  File "/usr/local/lib/python3.7/dist-packages/paho_mqtt-1.6.1-py3.7.egg/paho/mqtt/client.py", line 1045, in reconnect
    on_pre_connect = self.on_pre_connect
  File "/usr/local/lib/python3.7/dist-packages/paho_mqtt-1.6.1-py3.7.egg/paho/mqtt/client.py", line 1863, in on_pre_connect
    return self._on_pre_connect
AttributeError: 'Client' object has no attribute '_on_pre_connect'


Please help me... I don't find solution....
Previous Topic:Receiving Memory Allocation Error in Import
Next Topic:How to handle exception in loop thread
Goto Forum:
  


Current Time: Fri May 03 07:53:12 GMT 2024

Powered by FUDForum. Page generated in 0.03063 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top