and everything is working well initially. But after many hours, it stops responding to pings. Is there any way to add a simple watchdog to a project like this?
Setup started...
Connecting
[ 1454][W][WiFiGeneric.cpp:1407] setTxPower(): Neither AP or STA has been started
[WiFi-event]0
WiFi interface ready
[WiFi-event]2
WiFi client started
[WiFi-event]4
Connected to access point
[WiFi-event]7
o.
Wifi connected! IP:192.168.1.5
Setup Complete, starting server...
but here is my ping showing the board is unreachable for a time when I cover with tin foil. I’ll keep playing, but this seems like it’s going to work well, thanks again!!
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
Request timeout for icmp_seq 7
Request timeout for icmp_seq 8
Request timeout for icmp_seq 9
Request timeout for icmp_seq 10
Request timeout for icmp_seq 11
Request timeout for icmp_seq 12
Request timeout for icmp_seq 13
Request timeout for icmp_seq 14
Request timeout for icmp_seq 15
Request timeout for icmp_seq 16
Request timeout for icmp_seq 17
Request timeout for icmp_seq 18
Request timeout for icmp_seq 19
Request timeout for icmp_seq 20
Request timeout for icmp_seq 21
Request timeout for icmp_seq 22
Request timeout for icmp_seq 23
Request timeout for icmp_seq 24
Request timeout for icmp_seq 25
64 bytes from 192.168.1.5: icmp_seq=0 ttl=255 time=26632.296 ms
64 bytes from 192.168.1.5: icmp_seq=1 ttl=255 time=25630.972 ms
64 bytes from 192.168.1.5: icmp_seq=2 ttl=255 time=24629.793 ms
64 bytes from 192.168.1.5: icmp_seq=27 ttl=255 time=288.321 ms
64 bytes from 192.168.1.5: icmp_seq=28 ttl=255 time=108.083 ms
64 bytes from 192.168.1.5: icmp_seq=29 ttl=255 time=417.088 ms
64 bytes from 192.168.1.5: icmp_seq=30 ttl=255 time=216.332 ms
64 bytes from 192.168.1.5: icmp_seq=31 ttl=255 time=456.435 ms
64 bytes from 192.168.1.5: icmp_seq=32 ttl=255 time=198.182 ms
64 bytes from 192.168.1.5: icmp_seq=33 ttl=255 time=702.244 ms
64 bytes from 192.168.1.5: icmp_seq=34 ttl=255 time=715.689 ms
64 bytes from 192.168.1.5: icmp_seq=35 ttl=255 time=40.765 ms
Request timeout for icmp_seq 38
Request timeout for icmp_seq 39
Request timeout for icmp_seq 40
Request timeout for icmp_seq 41
Request timeout for icmp_seq 42
Request timeout for icmp_seq 43
Request timeout for icmp_seq 44
Request timeout for icmp_seq 45
Request timeout for icmp_seq 46
Request timeout for icmp_seq 47
Request timeout for icmp_seq 48
Request timeout for icmp_seq 49
Request timeout for icmp_seq 50
Request timeout for icmp_seq 51
Request timeout for icmp_seq 52
64 bytes from 192.168.1.5: icmp_seq=53 ttl=255 time=791.886 ms
64 bytes from 192.168.1.5: icmp_seq=54 ttl=255 time=192.314 ms
64 bytes from 192.168.1.5: icmp_seq=55 ttl=255 time=333.694 ms
Request timeout for icmp_seq 56
64 bytes from 192.168.1.5: icmp_seq=56 ttl=255 time=1010.432 ms
64 bytes from 192.168.1.5: icmp_seq=57 ttl=255 time=475.960 ms
64 bytes from 192.168.1.5: icmp_seq=58 ttl=255 time=1026.618 ms
64 bytes from 192.168.1.5: icmp_seq=59 ttl=255 time=1440.030 ms
64 bytes from 192.168.1.5: icmp_seq=60 ttl=255 time=1962.385 ms
64 bytes from 192.168.1.5: icmp_seq=61 ttl=255 time=1015.741 ms
64 bytes from 192.168.1.5: icmp_seq=62 ttl=255 time=59.394 ms
The latter was helpful for the example titled “Reconnect to Wi-Fi Network After Lost Connection (Wi-Fi Events)”, and the former was great for the full background.
Thanks for that note! The example in the link I shared actually uses a value “previousMillis” that is initialized to 0 but I think it’s better to initialize it to the current value of millis() because that prevents any reconnection attempt during the first defined interval of 30 seconds.
Hard to say without more testing, but so far at least it’s been running for 12 hours on two esp32s3 xiao boards. I’ll update here after a few days if all goes well.
I’m actually using this with hubitat, and found a nice shared example of a ping status that my Flutter app can query and display for the two xiao boards.
Your point is totally valid, and I originally tried to use the error code disconnect (5) to trigger a reset with the flags as you mentioned (boolean to record when server was started, and one to mark an ESP.restart() in main loop), but then found the disconnect and reconnect example in main loop and went that route.
The event handler is great though to see what’s going on better at the very least.
So with the randomnerd example, its working very well. I also added a simple endpoint to the server to be able to query a count of number of times either (I’m running two esp32c3’s) does a restart and one of the two has the count of 1 to confirm it has helped already.
Hello,
I use wifi event and a wathdog to the web socket.
With that, each side can know if connexion is lost.
The event socket close can go thru router.
So if it is a router between the server and the client, the only method is a watchdog.
Be careful, if the web client disconnect the displayed values is not accurate.
Enjoy javascript…
Best regards
Thierry