Left here for archival purposes.

User avatar
By TerryE
#16681 TCP is a connection oriented protocol -- which means that once the connection is established, the two ends use a pair of ports (not 8080 in this case) to talk to each other and even when the date transfer is quiescent, they still exchange keep-alive packets. If this process fails, for whatever reason, then the link is disconnected and the application at both ends is notified.

Your RPI process should keep the link up, and given this, then the main reason for a disconnect would this WiFi issue -- which as you say is very sporadic. Rebooting (say once or twice a day) is the best remedy here, IMO, as this is most likely to renegotiate the entire stack including WiFi properly.

As a general point very much +1 on your approach of keeping the IoT devices and their stacks local and simple. I am adopting the same approach. In my case the only external internet connection to my RPi is an SSL link from an application running on my public ellisons.org.uk. So my Android tablet on roam-about talks to an ellisons.org.uk URI which presents a publicly accessible portal with the necessary authentication, etc. This then talks to my RPi and my devices only talk to the RPi.

The idea of IoT devices talking directly over the Internet using HTTP / HTML horrifies me. In practice, any attacker would have to compromise my portal application, and then go via it then to compromise my HA system on the the RPi to get at my devices.

gschmott wrote:I think there is another useful RAM saving technique/approach/library mentioned here as well:
Massive memory optimization: flash functions

In terms of general memory saving techniques, the advice we give is the same, and our approach is pretty similar; it's just that we developed our implementations in parallel. :)
User avatar
By radu022003
#16725 I implemented some memory improvements and also checked the heap size during time and at least it should not run out of memory. An improvement I observed, it stays didisconnected only 15 min. I wonder if anyone else has tried to use esp8266 with a DD-WRT router maybe some parameters in wifi can be changed.
Also a method to restart the module when goes in this state, if someone has it would be very useful.
User avatar
By radu022003
#16924 What I did in the past days was to send together with temperature and adc value, the current heap size. What I observed is that the size of the heap is not decreased in time and also not had big differences which leads me to the ideea that the esp8266 has no memory problem, at least not in my case. What I also experienced is that on my android phone suddenly stopped the Internet acces and other clients also, even the router was not accessible anymore. Restarting the wifi made all work again.
I will search more about dd-wrt configuration and hopefully I will find a solution.
Now related to nodemcu, is a lack of functions, searching in the API I saw that is no chance to see if a connection was successful or not, because connect function is returning nothing, then you can not see if the connection was really successful or not (I could be using this to connect to router or at least trying) so in my case I don't know when to restart the wifi or complete module.
Also a ping command would also be very useful to have.
If I miss or wrote something wrong please comment it.

Thank you
User avatar
By radu022003
#17398 A few days ago I replaced the firmware of my router with the stock one. Now esp8266 is always connected, problems disappeared. I haven't being able to see why dd-wrt wasn't able to keep the connection on with esp8266.