You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add request timeout and Redis duplicate update prevention
- Added `Request::$timeout` and `Request::setClientTimeout` to control Guzzle client timeout.
- Added Redis update de-duplication in `Telegram::processUpdate`.
- Added `Telegram::setRedis` for injecting Redis instance.
- Added `Telegram::$update_retention_time` and `Telegram::setUpdateRetentionTime` to configure de-duplication TTL.
- Updated README.md with instructions.
- Default request timeout is set to 60 seconds.
- Duplicate updates are cached in Redis for 60 seconds (default) and return a fake success response.
Enabling Redis also activates the built-in duplicate update prevention mechanism. This is useful when the bot receives the same update multiple times due to timeouts or retries from Telegram.
120
+
121
+
When Redis is enabled:
122
+
1. The library checks if the `update_id` exists in Redis.
123
+
2. If it exists, the update is ignored, and a fake success response is returned to Telegram to stop retries.
124
+
3. If it doesn't exist, the `update_id` is stored in Redis with a retention time (TTL) of 60 seconds.
125
+
126
+
You can customize the retention time (in seconds):
To prevent your server from hanging on slow Telegram API requests (e.g., cURL error 28), you can set a custom timeout for the HTTP client. The default timeout is 60 seconds.
0 commit comments