-
I am trying to running a simple server on an ESP32 AP that listens for a few clients. I think I have ways of telling if the server part is running, however the system locks-up every day or so. Is there a way for the ESP32 itself to tell if the AP is running and then if not ... do a machine.reset()?? Would running asyncio with a server task and another task blinking an LED with a watchdog timer be able to tell me if the server parts locks-up? This what I am running as the server: while True:
try:
# allow for immediate re-use
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind((config.host, config.port))
except:
socket_count += 1
try:
with open('errors.txt', 'a') as outfile:
outfile.write('something failed at the socket stage' + '\n')
outfile.write('socket fail count' + str(socket_count) + '\n')
except OSError:
pass
machine.reset()
while True:
try:
server.listen()
client, address = server.accept()
break
except:
listen_count += 1
try:
with open('errors.txt', 'a') as outfile:
outfile.write('something failed at the listen stage' + '\n')
outfile.write('listen fail count' + str(listen_count) + '\n')
except OSError:
pass
# try starting again if listen fails
break |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 26 replies
-
One approach is to have a client which is expected to send heartbeat signals to your server. In this way, it doesnt matter what state your software/hardware gets into, but it does rely on at least one active heartbeat device on your network. You could use the heartbeat to feed a watchdog or have your watchdog task check the time since the last heartbeat and stop feeding the watchdog if the heartbeat has timed out. |
Beta Was this translation helpful? Give feedback.
-
use microdot as webserver. |
Beta Was this translation helpful? Give feedback.
One approach is to have a client which is expected to send heartbeat signals to your server. In this way, it doesnt matter what state your software/hardware gets into, but it does rely on at least one active heartbeat device on your network.
You could use the heartbeat to feed a watchdog or have your watchdog task check the time since the last heartbeat and stop feeding the watchdog if the heartbeat has timed out.