Photonpump should send heartbeat requests to the server
bobthemighty opened this issue · 3 comments
bobthemighty commented
If we close the connection from underneath photonpump, eg. by terminating a VPN tunnel, then the client never notices any difference.
We should periodically (suggest every 60 secs) send a heartbeat request to the server. If we fail some consecutive number of requests, we should issue a reconnection request to the connection handler.
bobthemighty commented
If we implement the Connector, per #9 then we can hook this logic up in there. We'll set up some kind of dead man's switch, and write events for HeartbeatRequested, HeartbeatReceived, and HeartbeatTimeout into the queue.
barrachri commented
something like this?
error = 0
async def send_heartbeat(time=60, error=error):
while True:
if error > 5:
await queue.put("HeartbeatError")
break
try:
await i_am_alive(url)
await queue.put("HeartbeatReceived")
except:
error += 1
await queue.put("HeartbeatFailed")
await asyncio.sleep(time)
bobthemighty commented
@barrachri This is implemented in 0.5
Your pseudo-code is pretty close!
We need to reconsider, though, as part of #49