Closed lwl12 closed 4 years ago
Trying to implement a decorator that put an infinite retry every 1 to 2 seconds to all major outgoing message requests (excluding polling).
Due to strange network problems, in a consecutive period of time, messages may appear "not delivered" by returning an HTTP Timed Out response, but is in fact sent. This causes messages to be sent infinitely and potentially triggers Telegram's Spam filter. So this feature is turned off by default to prevent such issue to happen.
I have written an article explaining how difficult to solve this issue on the current architecture due to constraints of the Telegram Bot API.
I would only see this might have improvement if we migrate to MTProto API which could resolve some (but not all) of the issue we have there. Migration to MTProto is possible in the future (together with framework-wide support to Python async) but I don’t currently have any plan on it.
Create a queue for all undelivered messages, have a thread in parallel that checks if if there is message in the queue in a fixed in a fixed interval. If found, dequeue and resend, enqueue it back when failed.
Original content (chatlog)
liwanglin12 Unofficial: @blueset 话说 telegram 服务器临时连接不上造成的丢消息 能重发么 Eana Hufwe: 目前是使用的 PTB 的5次重试策略 5次重试都不行就输出到 log liwanglin12 Unofficial: 感觉能不能有一个机制 比如定期检测一下连通性 (比如利用updates 这个五次重试不行的 拉个库存起来 一旦链接恢复就重发 另外给main.py加一个让他重发的能力 主动重连 ( Eana Hufwe: 倒是可以搞一个 stack 隔一段时间检查一次 nice idea 到 ETM v2 repo 丢一个 issue 吧(俺可能会忘……(( 话说这个「主动重连」是什么意思 liwanglin12 Unofficial: 比如 python3 main.py command updateetm Eana Hufwe: 哦哦