MQTT code freeze after some time.
MQTT code freeze after some time.
Hello, i have a mqtt code with subscribe method i my ESP32 with latest micropython build.
After some time, code froze and i cant receive more updates from subscribe.
I try to put gc.collect in code to clean garbage but not works.
Any solutions to this?
After some time, code froze and i cant receive more updates from subscribe.
I try to put gc.collect in code to clean garbage but not works.
Any solutions to this?
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: MQTT code freeze after some time.
Please give us more information on what libraries you use and your code.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Re: MQTT code freeze after some time.
Hello, i'm use this library: https://github.com/micropython/micropyt ... qtt.simple,
and this https://docs.micropython.org/en/latest/ ... ujson.html.
I'm use ujson to get a js from outher publisher device and execute based on command received.
and this https://docs.micropython.org/en/latest/ ... ujson.html.
I'm use ujson to get a js from outher publisher device and execute based on command received.
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: MQTT code freeze after some time.
Please show us your code otherwise it would be just guesswork.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: MQTT code freeze after some time.
While I agree with @kevinkk525 - there is little we can say without seeing your code - you could debug it yourself by issuing ctrl-c at the REPL when it hangs. The traceback will tell you what it was doing at the time, which might give you some clues. And us, if you show us your code and the traceback.
You might also read my notes on achieving reliable connections on WiFi. This was based on experience of myself and @kevinkk525 on the pitfalls on offer.
You might also read my notes on achieving reliable connections on WiFi. This was based on experience of myself and @kevinkk525 on the pitfalls on offer.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: MQTT code freeze after some time.
I can't see any obvious error and you have plenty of exception trapping in place. When it fails, do you get no output from your exception handlers? What happens if you enter ctrl-c after faulure?
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: MQTT code freeze after some time.
Hmm me neither. Any connection problem should result in a reset in that code.
Might be helpful to know what exactly is happening when the device doesn't react anymore.
Might be helpful to know what exactly is happening when the device doesn't react anymore.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Re: MQTT code freeze after some time.
@python coder and @kevinkk525 codes just freeze and dont receive any updates anymore.
I try to press ctrl+c to get error.
I try to press ctrl+c to get error.
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: MQTT code freeze after some time.
You could implement a publish every 10 seconds and a console output. Then you would see if the connection or the device itself freeze.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode