Skip to content

fix: a new Telegram connection for each message, one more try (#295) - #296

Merged
giosci1994 merged 1 commit into
mainfrom
fix/295-telegram-stale-connection
Nov 17, 2026
Merged

giosci1994 merged 1 commit into
mainfrom
fix/295-telegram-stale-connection

Conversation

@giosci1994

Copy link
Copy Markdown
Member

Closes #295

What changes

  • Telegram no longer keeps a requests.Session. Each message goes out with requests.post on a connection of its own. A session can still be passed in for tests.
  • A message that fails on the connection (ConnectionError, Timeout) is tried once more after 3 s. An answer from Telegram, such as 400 "chat not found", is not tried again. The error never contains the token, as before.
  • Tests: a timeout and then success (two tries, one wait), always failing (two tries, then the error), refused (one try), no session (requests.post). CHANGELOG ("Unreleased").

Why

From 2026-11-11 to 2026-11-16 the owner's server logged the Telegram sends as failed, OK, failed, OK… with ReadTimeout. Telegram answers in about 0.1 s from the same container. After a successful send, the pooled connection is reused hours later, after it was dropped on the way, so the next message hangs until the 15 s timeout. Update messages then arrive 6 hours late; an alert is lost (the "unhealthy" alert of a VPN container on 2026-11-15).

How it was tested

pytest: 94 passed. pyflakes is clean. Not tried by sending real messages, which would reach the owner's chat. On the server, the next days' log will show whether every send passes.

Checklist (see AGENTS.md, "Before opening a pull request")

  • Only my area, or the other agent agreed in the issue
  • Facts checked at the source (branches, issues, code), nothing assumed
  • pyflakes and pytest pass; new behaviour or fixed bug has a test
  • Tried for real (demo or throwaway container), both languages and themes for UI — unit tests only (see above)
  • Unix line endings, no permission changes
  • No secrets, personal data or details of the owner's setup (code, docs, screenshots, messages)
  • CHANGELOG.md / API.md / README updated where needed
  • I read my whole diff

Reviewer (the other agent): run the tests, then comment "Review by : approved" or "Review by : changes requested" with the findings.

🤖 Generated with Claude Code

One Telegram message out of two timed out: the session kept the
connection between messages hours apart, long dropped on the way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@giosci1994 giosci1994 added bug Something isn't working claude Task for Claude (the app, the owner's server) labels Nov 17, 2026
@giosci1994
giosci1994 merged commit c519435 into main Nov 17, 2026
3 checks passed
@giosci1994
giosci1994 deleted the fix/295-telegram-stale-connection branch November 17, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working claude Task for Claude (the app, the owner's server)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram: every other message times out on a stale kept-alive connection

1 participant