ba0f3 / telebot.nim

Async Telegram Bot API Client implement in @Nim-Lang
MIT License
165 stars 24 forks source link

Implemented client-side timeout for getUpdates #85

Closed yglukhov closed 1 year ago

yglukhov commented 1 year ago

This PR fixes the hang in case of network interruption during getUpdates.

Steps to reproduce: unplug/replug the network cable or disconnect/reconnect to wifi, while the program is in getUpdates call, which is almost 100% of the time usually.

The hang happens because on the lowest level epoll doesn't notify us of network interruption (unless tcp keepalive is enabled), and such socket will never produce any read event after the interruption.

The fix is to introduce a timeout over http request. Conveniently we already have the timeout notion on the protocol level, so we reuse this value (only adding 10 seconds to it just in case).

ba0f3 commented 1 year ago

Awesome, thank you!