fix(matrix): tune sync transport timeouts
This commit is contained in:
parent
14c091b5f5
commit
6a843e8036
1 changed files with 18 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ from pathlib import Path
|
|||
import structlog
|
||||
from nio import (
|
||||
AsyncClient,
|
||||
AsyncClientConfig,
|
||||
InviteMemberEvent,
|
||||
MatrixRoom,
|
||||
ReactionEvent,
|
||||
|
|
@ -186,14 +187,23 @@ async def main() -> None:
|
|||
password = os.environ.get("MATRIX_PASSWORD")
|
||||
token = os.environ.get("MATRIX_ACCESS_TOKEN")
|
||||
db_path = os.environ.get("MATRIX_DB_PATH", "lambda_matrix.db")
|
||||
store_path = os.environ.get("MATRIX_STORE_PATH", "matrix_store")
|
||||
if not homeserver or not user_id:
|
||||
raise RuntimeError("MATRIX_HOMESERVER and MATRIX_USER_ID are required")
|
||||
|
||||
client_config = AsyncClientConfig(
|
||||
request_timeout=120,
|
||||
max_timeouts=12,
|
||||
max_limit_exceeded=20,
|
||||
backoff_factor=0.5,
|
||||
max_timeout_retry_wait_time=15,
|
||||
)
|
||||
client = AsyncClient(
|
||||
homeserver,
|
||||
user=user_id,
|
||||
device_id=device_id,
|
||||
store_path=os.environ.get("MATRIX_STORE_PATH"),
|
||||
store_path=store_path,
|
||||
config=client_config,
|
||||
)
|
||||
runtime = build_runtime(store=SQLiteStore(db_path), client=client)
|
||||
if token:
|
||||
|
|
@ -206,7 +216,13 @@ async def main() -> None:
|
|||
client.add_event_callback(bot.on_reaction, ReactionEvent)
|
||||
client.add_event_callback(bot.on_member, (InviteMemberEvent, RoomMemberEvent))
|
||||
|
||||
logger.info("Matrix bot starting")
|
||||
logger.info(
|
||||
"Matrix bot starting",
|
||||
homeserver=homeserver,
|
||||
user_id=user_id,
|
||||
store_path=store_path,
|
||||
request_timeout=client_config.request_timeout,
|
||||
)
|
||||
try:
|
||||
await client.sync_forever(timeout=30000)
|
||||
finally:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue