Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add periodic connection refresh #964

Merged
merged 5 commits into from
May 24, 2024
Merged

Add periodic connection refresh #964

merged 5 commits into from
May 24, 2024

Conversation

javiercr
Copy link
Member

@javiercr javiercr commented May 23, 2024

Context

We've observed some scenarios where users stop getting messages. Reconnecting them seems to solve the issue.

Description

This PR adds a new force_refresh_interval_seconds config option to force the connection to be refreshed. Default is 0 (disables force refresh). This is the equivalent to mautrix/meta#58.

How to test this

Clone the branch, change force_refresh_interval_seconds to a small interval (eg: 10 seconds), run the bridge locally and you should see:

[2024-05-23 17:08:38,712] [INFO@mau.user.@REDACTED] Scheduling forced reconnect in 20 seconds. Connection will be refreshed at 2024-05-23 17:08:58

[2024-05-23 17:08:58,714] [INFO@mau.user.@REDACTED] Reconnecting to Telegram...
[2024-05-23 17:08:58,716] [INFO@telethon.611285941.network.mtprotosender] Disconnecting from 149.154.167.91:443/TcpFull...
[2024-05-23 17:08:58,720] [INFO@telethon.611285941.network.mtprotosender] Disconnection from 149.154.167.91:443/TcpFull complete!
[2024-05-23 17:08:58,722] [INFO@telethon.611285941.client.updates] Update loop finished
[2024-05-23 17:08:58,740] [INFO@telethon.611285941.client.telegrambaseclient] Saving update states
[2024-05-23 17:08:58,741] [DEBUG@mau.user.@REDACTED] Initializing client for @REDACTED
[2024-05-23 17:08:58,742] [INFO@mau.user.@REDACTED] Scheduling forced reconnect in 20 seconds. Connection will be refreshed at 2024-05-23 17:09:18
[2024-05-23 17:08:58,742] [INFO@telethon.611285941.network.mtprotosender] Connecting to 149.154.167.91:443/TcpFull...
[2024-05-23 17:08:58,775] [INFO@telethon.611285941.network.mtprotosender] Connection to 149.154.167.91:443/TcpFull complete!

[2024-05-23 17:09:18,743] [INFO@mau.user.@REDACTED] Reconnecting to Telegram...
[2024-05-23 17:09:18,743] [INFO@telethon.611285941.network.mtprotosender] Disconnecting from 149.154.167.91:443/TcpFull...
[2024-05-23 17:09:18,744] [INFO@telethon.611285941.network.mtprotosender] Disconnection from 149.154.167.91:443/TcpFull complete!
[2024-05-23 17:09:18,744] [INFO@telethon.611285941.client.updates] Update loop finished
[2024-05-23 17:09:18,745] [INFO@telethon.611285941.client.telegrambaseclient] Saving update states
[2024-05-23 17:09:18,746] [DEBUG@mau.user.@REDACTED] Initializing client for @REDACTED
[2024-05-23 17:09:18,746] [INFO@mau.user.@REDACTED] Scheduling forced reconnect in 20 seconds. Connection will be refreshed at 2024-05-23 17:09:38

Make sure you're still able to send and receive messages.

@javiercr javiercr requested a review from tulir May 23, 2024 15:11
mautrix_telegram/abstract_user.py Outdated Show resolved Hide resolved
mautrix_telegram/example-config.yaml Outdated Show resolved Hide resolved
@javiercr javiercr requested a review from tulir May 24, 2024 07:39
Copy link
Member

@tulir tulir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sensible

@javiercr javiercr merged commit f6cb26f into master May 24, 2024
5 checks passed
@javiercr javiercr deleted the feature/periodic-refresh branch May 24, 2024 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants