Arcana / node-dota2-bot

Wrapper around the node-dota2 library which handles all log-in shenanigans
MIT License
9 stars 7 forks source link

Handle GC restarts, timeouts, disconnects #1

Closed Crazy-Duck closed 8 years ago

Crazy-Duck commented 8 years ago

Implement graceful handling of service interruptions

Crazy-Duck commented 8 years ago

@jimmydorry could you elaborate on what you consider graceful handling of the above? I'd love to see your view on things before I start implementing further stuff

jimmydorry commented 8 years ago

Will write up a more detailed response tomorrow, but basically i meant handling of GC restart events, connection drops (i.e. when you lose internet for a few seconds locally), and steam timeouts (i.e. patch tuesdays).

jimmydorry commented 8 years ago

This was the last time I recall the issue cropping up. https://github.com/RJacksonm1/node-dota2/issues/105

I don't know how node-steam has changed (whether it now handles this), but your bot framework should consider handling connection states, especially around the GC restarts.

Crazy-Duck commented 8 years ago

Alright, I added some basic keep alive code. Node-dota2 seems to handle GC disconnects on its own, so I focused on keeping the Steam connection alive (for which I based myself on how @howardchung uses the lib in yasp). It should now reconnect when it detects a dc. This leaves the problem of requests failing because they're sent while GC isn't ready. Since all communication with the GC is async anyways, I'm thinking about adding a job process queue. This queue would execute in FIFO all requests and retry (with exponential back-off) if one fails cause GC isn't ready. Thoughts?

jimmydorry commented 8 years ago

Sounds awesome.

Crazy-Duck commented 8 years ago

Queueing added. You pass a function to the bot and it will schedule it for execution as soon as the GC is available. If GC is unavailable the queue applies exponential backoff for retries

jimmydorry commented 8 years ago

Wow, that is crazy useful.