peterhinch / micropython-samples

Assorted code ideas, unofficial MP FAQ, plus index to my other repositories.
MIT License
442 stars 91 forks source link

Resilient Example #6

Open gampam2000 opened 5 years ago

gampam2000 commented 5 years ago

Hi, great work, I think I encountered similar problems with my application (a number of ESP8266 with temperature sensors) witch stop working after some time because of open sockets. Interestingly with older version of 1.9.x I just got an Exception and LmacRxBlk:1 errors and made a hard reset to recover, but now with the latest version of micropython the network is just dead and all other async tasks just run normal. I started to print out socket.print_pcbs() and when the open connection count reaches 5 as you already mentioned it just stops working. Because I get no exception I'm not shure if your code would really help me. What do you think?

peterhinch commented 5 years ago

This code is a proof of concept which would need adapting for your application.

I am developing a solution based on these ideas where a server-side application communicates with multiple ESP8266 boards via a resilient UART-like interface. The server-side application would run on a machine with a wired interface (e.g. a Raspberry Pi) and would use CPython, enabling access to full-fat internet libraries. In typical applications the user code on the ESP8266 would be quite simple. The user code on the server would handle communications between ESP8266 nodes and would perform the internet-facing tasks (if required).

This seems to me a better way to achieve resilience than attempting to run web applications on the ESP8266.

Until I'm in a position to release this your options are either to adapt this code for your applications or to consider my asynchronous resilient MQTT solution.