RSSHub icon indicating copy to clipboard operation
RSSHub copied to clipboard

Can't get telegram channel from k8s - FetchError: [GET] ...: <no response> fetch failed

Open ppoloskov opened this issue 2 months ago • 11 comments

Routes

/telegram/channel/:username/:routeParams?

Full routes

/telegram/channel/awesomeRSSHub

Related documentation

https://docs.rsshub.app/routes/popular#channel

What is expected?

I can get contents of the channel

What is actually happening?

FetchError: [GET] "https://t.me/s/awesomeRSSHub": <no response> fetch failed
Route: /telegram/channel/:username/:routeParams?
Full Route: /telegram/channel/awesomeRSSHub
Node Version: v22.20.0
Git Hash: e03111c5
Git Date: Sun, 19 Oct 2025 16:06:18 GMT

I can curl from inside the container:

kubectl exec -n media rsshub-0 -it -- sh
Defaulted container "rsshub" out of: rsshub, browserless
# curl https://t.me/s/awesomeRSSHub
<!DOCTYPE html>
<html>
  <head>
....

Complete log:

info: <-- GET /telegram/channel/awesomeRSSHub
debug: Matched route: /telegram/channel/:username/:routeParams?
debug: Outgoing request: GET https://t.me/s/awesomeRSSHub
error: Request https://t.me/s/awesomeRSSHub fail: AggregateError TypeError: fetch failed
debug: Outgoing request: GET https://t.me/s/awesomeRSSHub
error: Request https://t.me/s/awesomeRSSHub fail: AggregateError TypeError: fetch failed
debug: Outgoing request: GET https://t.me/s/awesomeRSSHub
error: Request https://t.me/s/awesomeRSSHub fail: AggregateError TypeError: fetch failed
error: Error in /telegram/channel/awesomeRSSHub: FetchError: [GET] "https://t.me/s/awesomeRSSHub": <no response> fetch failed
info: --> GET /telegram/channel/awesomeRSSHub 503 3s

Deployment information

Self-hosted

Deployment information (for self-hosted)

k3s kubernetes on bare-metal alpine host

Additional info

Container image ghcr.io/diygod/rsshub:chromium-bundled-2025-10-19" (both with and without chrome).

This is not a duplicated issue

  • [x] I have searched existing issues to ensure this bug has not already been reported

ppoloskov avatar Oct 20 '25 05:10 ppoloskov

Searching for maintainers:
  • /telegram/channel/:username/:routeParams?: @DIYgod @Rongronggg9 @synchrone @pseudoyu

To maintainers: if you are not willing to be disturbed, list your username in scripts/workflow/test-issue/call-maintainer.js. In this way, your username will be wrapped in an inline code block when tagged so you will not be notified.

If all routes can not be found, the issue will be closed automatically. Please use NOROUTE for a route-irrelevant issue or leave a comment if it is a mistake. 如果所有路由都无法匹配,issue 将会被自动关闭。如果 issue 和路由无关,请使用 NOROUTE 关键词,或者留下评论。我们会重新审核。

github-actions[bot] avatar Oct 20 '25 05:10 github-actions[bot]

Hi @ppoloskov! I'm Dosu and I’m helping the RSSHub team.

The Telegram channel route in RSSHub fetches https://t.me/s/:username using Node.js HTTP fetch (specifically ofetch), not curl or a browser. If curl works but Node.js fetch fails in your k8s container, it's likely due to differences in how Node.js handles DNS, TLS, proxies, or request headers compared to curl. This can happen if your Kubernetes network setup, firewall, or proxy configuration affects Node.js but not curl, or if Telegram is blocking requests based on user-agent or other headers source.

To troubleshoot: try setting the PROXY_URI environment variable to route Telegram requests through a proxy, adjust REQUEST_TIMEOUT and REQUEST_RETRY for more robust fetches, and experiment with custom headers (like User-Agent) if possible. If the channel is restricted, you may need to set up Telegram API credentials (TELEGRAM_SESSION, TELEGRAM_API_ID, TELEGRAM_API_HASH) to fetch via the Telegram API instead of scraping source.

If you want to confirm the root cause, enable debug logs in RSSHub to see if there are DNS, TLS, or HTTP errors, and compare the request headers sent by curl and Node.js fetch. If the issue persists, try deploying RSSHub outside Kubernetes or on a different network to rule out cluster-level restrictions.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

dosubot[bot] avatar Oct 20 '25 05:10 dosubot[bot]

@dosu How to enable debug logs in RSSHub? Also, I have NODE_ENV set to dev, but looks like container ignores it

ppoloskov avatar Oct 21 '25 06:10 ppoloskov

To enable debug logs in RSSHub, set the environment variable LOGGER_LEVEL=debug in your container. This will increase log verbosity and show debug-level messages in the logs. The NODE_ENV variable does not control logging verbosity in RSSHub; it's only used for error message display on authentication failures and is typically ignored for logging purposes in the container image. For more details, see the deployment config documentation.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

dosubot[bot] avatar Oct 21 '25 06:10 dosubot[bot]

@dosu I don't get anything new from debug logs: info: <-- GET /telegram/channel/awesomeRSSHub debug: Matched route: /telegram/channel/:username/:routeParams? debug: Outgoing request: GET https://t.me/s/awesomeRSSHub error: Request https://t.me/s/awesomeRSSHub fail: AggregateError TypeError: fetch failed debug: Outgoing request: GET https://t.me/s/awesomeRSSHub error: Request https://t.me/s/awesomeRSSHub fail: AggregateError TypeError: fetch failed debug: Outgoing request: GET https://t.me/s/awesomeRSSHub error: Request https://t.me/s/awesomeRSSHub fail: AggregateError TypeError: fetch failed error: Error in /telegram/channel/awesomeRSSHub: FetchError: [GET] "https://t.me/s/awesomeRSSHub": fetch failed info: --> GET /telegram/channel/awesomeRSSHub 503 3s

ppoloskov avatar Oct 21 '25 06:10 ppoloskov

@dosu What else can I do to debug?

ppoloskov avatar Oct 21 '25 06:10 ppoloskov

Here are some deeper debugging steps you can try:

  1. Compare curl and Node.js fetch headers: Telegram may block requests based on headers. Curl works, but Node.js fetch (used by RSSHub) might send a different User-Agent or lack cookies. You can patch the route code (lib/routes/telegram/channel.ts) to add a browser-like User-Agent header to the ofetch call, or use a proxy that rewrites headers. Docs

  2. Use a proxy: Set the PROXY_URI environment variable to route Telegram requests through a proxy. This can help bypass network restrictions or anti-crawler measures. Docs

  3. Increase timeout and retries: Set REQUEST_TIMEOUT and REQUEST_RETRY to higher values in your environment to make fetches more robust against transient failures. Docs

  4. Try Telegram API mode: If the channel is restricted or anti-crawler measures are in place, set up Telegram API credentials (TELEGRAM_SESSION, TELEGRAM_API_ID, TELEGRAM_API_HASH) to fetch via the Telegram API instead of scraping. Docs

  5. Enable route-level debug output: Set debugInfo=true in your environment, then access /telegram/channel/awesomeRSSHub?format=debug.json to get detailed route-level debug output (if the route supports it). Advanced debug

  6. Test outside Kubernetes: Try running RSSHub locally or in a different container runtime to rule out cluster-level restrictions.

If you want to go further, you can modify the route handler to log the full error stack and all request/response headers for the failing fetch. This isn't built-in, but can be added easily in code. If Telegram is blocking Node.js fetches, using Puppeteer or a headless browser is a last resort.

Let me know if you want code snippets for header customization or more details on any of these steps.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

dosubot[bot] avatar Oct 21 '25 06:10 dosubot[bot]

Still no success

ppoloskov avatar Oct 28 '25 03:10 ppoloskov

I found an issue, it's related to ipv4/ipv6 resolution. Looks like default configuration of k3s poorly supports dual stack. This little fix resolved it for me disabling autoSelectFamily. I've tried env vars, but looks like ofetch ignores them. @DIYgod is this something you'll willing to include to the codebase?

// preload.js, add "--require /fix/preload.js" to args

const { setGlobalDispatcher, Agent } = require('/app/node_modules/undici');
setGlobalDispatcher(new Agent({ connect: { autoSelectFamily: false } }));

ppoloskov avatar Dec 05 '25 01:12 ppoloskov

@ppoloskov this should probably be solved at k8s deployment level. Have you tried adding --no-network-family-autoselection to cli or NODE_OPTIONS?

synchrone avatar Dec 05 '25 10:12 synchrone

@ppoloskov this should probably be solved at k8s deployment level. Have you tried adding --no-network-family-autoselection to cli or NODE_OPTIONS?

@synchrone I’ve tried both cli args and env vars, but it didn’t work.

ppoloskov avatar Dec 05 '25 11:12 ppoloskov