🛠️ Real incident, fixed with AI

Recognizing Automatic Recovery from a Telegram Network Timeout

How to tell when a Telegram network timeout in Hermes has already recovered on its own.

In short

Hermes looked frozen in Telegram, but the gateway was still running. A short network timeout put Telegram in retrying, and Hermes rebuilt its Telegram adapter (the piece that talks to Telegram) by itself. No restart was required. Wait, recheck, and restart only if it is still failing after the network is back.

What you need

Check that it is retrying, not stopped

  1. Read the service, the process, the state file, and the heartbeat:
hermes gateway status

ps -eo pid,ppid,stat,etime,%cpu,%mem,wchan:24,cmd \
  | grep -E '[h]ermes_cli.main gateway run|[h]ermes.*gateway'

jq '{gateway_state,active_agents,platforms,updated_at}' \
  ~/.hermes/gateway_state.json

stat -c '%y %n' ~/.hermes/state/gateway.heartbeat

The process was sleeping normally. It was not in state T (job-control stopped). Hermes reported:

Telegram polling degraded
Telegram network error
telegram-init timed out
rebuilding the adapter
  1. Test the path to Telegram from this machine:
getent ahostsv4 api.telegram.org

curl -4 -sS -o /dev/null \
  -w 'HTTP %{http_code}, connect=%{time_connect}s, total=%{time_total}s\n' \
  --connect-timeout 5 \
  --max-time 12 \
  https://api.telegram.org/

The VM hit a short timeout while polling Telegram. The old updater did not stop before Hermes’s recovery deadline, so Hermes threw it away and built a new adapter.

This was not a dead gateway. The main process stayed up, Hermes kept updating state, the recovery queue stayed active, and the network came back with no action. curl got an HTTP response from api.telegram.org.

After the rebuild, state was gateway_state running, active_agents 0, telegram.state connected, and telegram.error_code null.

Restart only if it stays broken

  1. Wait and read the state again:
sleep 15
jq '{gateway_state,active_agents,platforms,updated_at}' \
  ~/.hermes/gateway_state.json
  1. Restart only if Telegram is still retrying or error, the heartbeat time has stopped moving, and the curl test above succeeds:
hermes gateway restart

Warning: repeated restarts during a real network outage do not fix the route, and they interrupt work the agent is doing. If you restarted once into an outage, wait for curl to succeed before you restart again.

If it doesn’t work

Official sources

Spot something wrong or outdated? Leave a comment below. Every comment is reviewed to keep these posts accurate.

By commenting, you agree to our Terms of use and confirm this is your own work. Short quotes are fine with a credit and link. Copied, unsafe, or abusive comments are removed. See something copied? Say so here.