mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6327] [Feature]: Support multiple telegram api url #4299
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4299
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bincrew on GitHub (Aug 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6327
Is your feature request related to a problem?
In regions where the official Telegram API (api.telegram.org) is blocked (e.g., Russia), users running a local 3x-ui panel must route Telegram bot traffic through a custom base URL pointing to an Nginx reverse proxy hosted on an external, unrestricted VPS.
Currently, 3x-ui only allows specifying a single Telegram API URL/proxy. This creates a Single Point of Failure (SPOF):
If the remote VPS hosting the Nginx reverse proxy loses connectivity or goes offline, 3x-ui cannot reach Telegram.
As a result, critical system notifications — including alerts that the node itself went offline or recovered — fail to deliver because the notification delivery mechanism relies on the very server that went down.
Describe the solution you'd like
Add support for multiple Telegram API base URLs with automatic fallback execution.
Proposed Behavior:
Sequential Retry: When sending a bot notification, 3x-ui sends the request to the primary Telegram API URL/proxy.
Failover: If the request fails (e.g., connection timeout, HTTP 5xx errors, or socket errors), 3x-ui automatically retries using the secondary URL, tertiary URL, etc., before giving up.
UI Configuration:
Allow entering comma-separated or newline-separated URLs in the custom Telegram API Base URL field, or
Provide an explicit list/array input for fallback Telegram API URLs.
Alternatives you've considered
External Load Balancers (HAProxy / DNS Failover): Configuring external HAProxy nodes or dynamic DNS failover across multiple VPS servers works, but it adds significant operational complexity, cost, and infrastructure overhead for a setup that could be handled natively within 3x-ui application logic.
Concrete use case
Many 3x-ui users already maintain multi-node deployments across several remote VPS instances. Allowing 3x-ui to natively failover Telegram API requests across these existing nodes would drastically increase notification reliability without requiring extra infrastructure.
Mockups, screenshots, or examples
No response
Which parts of the panel would this affect?
No response
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Aug 25, 2026):
You're right about the current limitation — 3x-ui stores and uses exactly one Telegram Bot API base URL, and nothing in the code splits, iterates or fails over that value. But the single point of failure you describe can already be removed today without a second API URL, using Panel Traffic Outbound plus an Xray balancer. Details below.
What the code does now
tgBotAPIServeris a single string setting (internal/web/service/setting.go:77, getter/setter at:534-540), validated as one URL:SanitizeHTTPURL(internal/web/service/url_safety.go:16-40) runsurl.Parseon the whole field, so a comma- or newline-separated value is never split into a list anywhere.It is then handed to the bot once, at construction:
The retry loop in
SendMsgToTgbotdoes exist, but it retries the same endpoint —internal/web/service/tgbot/tgbot_send.go:145-172, three attempts with 1s/2s/4s backoff:So when your Nginx relay VPS is down, all three attempts fail against the same host and the alert is dropped with
logger.Warning("Error sending telegram message:", err)(tgbot_send.go:169).For whoever picks this up: it is not a purely send-side change.
botis a single package-level*telego.Bot(tgbot.go:32) whose API server is fixed at construction, and the update stream is bound to that same object —bot.UpdatesViaLongPolling(ctx, ¶ms)(internal/web/service/tgbot/tgbot_router.go:41) behind a strict singleton guard (tgbot_router.go:24-30). Failing over would have to move the long-polling receiver too, not just outgoing messages.What you can do today
Since v3.7.0 the panel can route its own egress (including Telegram) through an Xray outbound — and that setting accepts a balancer tag, which is exactly the multi-endpoint failover you're asking for, one layer lower:
Concretely:
balancersentry listing those tags.panelOutbound) — the picker shows a separate Balancers group (frontend/src/pages/settings/GeneralTab.tsx:119-137); select the balancer.tgBotAPIServer) empty, so the bot talks toapi.telegram.orgdirectly and the tunnel — not an Nginx relay — is what crosses the border. That removes the relay from the path entirely.burstObservatoryand aleastPingstrategy to the balancer. BothobservatoryandburstObservatoryare first-class fields of the panel's generated config (internal/xray/config.go:23-24), so they survive config generation.Two caveats worth knowing:
PanelEgressProxyURL()returns""and the panel falls back to a direct connection, with a warning in the log (internal/web/service/setting.go:477-498).tgbot.go:299-306, and the comment there says so). That is fine for failover, though — the resolved value is a loopback SOCKS address; the actual per-connection failover happens inside Xray's balancer, so a dead member does not require a bot restart.Settings reference:
docs/content/docs/en/operations/telegram-bot.mdx(Settings table,tgBotProxy/tgBotAPIServer) anddocs/content/docs/en/config/panel.mdx(panelOutbound).Related, not a duplicate: #5058 asked for Telegram over a custom outbound and is what
panelOutboundcame from; it does not cover a list of API base URLs, so your request stands on its own. I left theenhancementlabel and the title as they are.Verdict: Feature request
This reply was generated automatically; a maintainer may follow up.