fizista / micropython-umqtt.simple2

MIT License
74 stars 35 forks source link

connectOSError: -202 #4

Closed mat-l closed 3 years ago

mat-l commented 3 years ago

Describe the bug File "/umqtt/simple2.py", line 53, in connectOSError: -202

To Reproduce I am using your example code from here (https://github.com/fizista/micropython-umqtt.simple2/blob/master/example_sub.py) to publish every 60 seconds a value to my MQTT broker.

def mqtt_pub(server="xx.xx.xx", pub_topic="", pub_value=""):
    c = MQTTClient("umqtt_client_pub", server)
    c.connect()
    time.sleep(.5)
    c.publish(pub_topic, str(pub_value))
    time.sleep(.5)
    c.disconnect()

After a while I am getting the connection error above and no mqtt message is published anymore. Even though the function "mqtt_pub" is called every time. Any ideas how I can avoid this error?

Details (please complete the following information):

fizista commented 3 years ago

Check if the server port 1883 is active, and if there is encryption on this port or not.

mat-l commented 3 years ago

Everything was active. Guess connecting and disconnecting everytime made some trouble after a while. I have switched to robust2 and I am now only connecting once in my mqtt communication class. Therefore the error is gone.

elvis-epx commented 1 year ago

It could be because the old sockets are not garbage-collected?