Skip to content

The production server cannot reach Petersburg's diary at all: the city's network drops connections from outside Russia #235

Closed

Description

@lumenpearson

What is broken

No family can use the Petersburg diary through this project, whatever the app does. The St Petersburg city network that hosts dnevnik2.petersburgedu.ru answers nothing to an address outside Russia. The server runs on Vercel in Frankfurt (fra1), and every Petersburg call the server makes goes out from there.

The phone's own sign-in (#140) does not get around this. POST /api/v1/diary/session adopts the phone's session with one read from the server's own address (PetersburgProvider.adopt, server/app/providers/petersburg/provider.py:100). Every diary read after that, /students, the lessons, the marks and the bot's «Дневник», is also made from the server.

This answers the question section 5 of HANDOVER.md left open: «A diary that ties a session to its address, or refuses foreign ones…». It refuses foreign ones, and it does so below HTTP: there is no 409 or 403 to read, only silence.

Failure scenario, as measured on 2 October 2026

  • POST https://lessons-ruddy-zeta.vercel.app/api/v1/diary/login with a made-up login and "provider": "petersburg" answered 503, X-Diary-Unavailable: upstream, {"detail":"Дневник не ответил вовремя"}, in 5.85 s. That is the 5-second connect timeout in petersburg/client.py:77, not a judgement on the password.
  • From a cloud session outside Russia, PetersburgClient.login gave up the same way after 7.1 s. curl showed the tunnel opening and then no TLS answer at all until the timeout.
  • Same probe, same moment, 20-second ceiling:
Host Result
dnevnik2.petersburgedu.ru (46.243.177.102/103) no answer
petersburgedu.ru no answer
www.spb.ru no answer
www.gosuslugi.ru 200, TLS in 3.5 s
ya.ru 302, TLS in 0.9 s
github.com answered in 0.3 s

The whole city government network is closed to the outside while federal and commercial Russian hosts are open. That is a geo-fence, not an outage of the diary.

What is ruled out

  • The server's own handling. The timeout fires, _guard turns UpstreamUnavailable into a 503 with its header, and the login limiter forgives it.
  • The production deployment itself. /api/v1/health, /api/v1/warmup (schema: 0017) and /api/v1/diary/capabilities (Petersburg enabled) all answer in under 1.5 s.

What a fix has to be

No app change can make Frankfurt reach the city's network. The Petersburg traffic the server sends has to leave from a Russian address. The options, smallest first:

  1. A Russian egress for diary traffic only. Add an optional setting, for example DIARY_PROXY_URL, that the Petersburg httpx client (and the NetSchool one, if their regions turn out to be fenced too) passes as proxy=. Point it at a password-protected HTTP proxy on a small Russian VPS. Optional, logged in Settings.disabled_features when unset, and kept off the mandatory list in get_settings(). Renting and running the VPS is the owner's step.
  2. Move the server to Russian hosting. A larger move, which would also settle the 152-ФЗ question section 5 already raises about personal data held in Frankfurt.
  3. Let the phone read the diary itself, since it is in Russia. A rewrite of the diary's server half; the corrections and the bot's diary both live there.

Not checked

Related: #121 (open the real dnevnik2 once), #143.

Activity

  1. lumenpearson commented on Oct 5, 2026

    @lumenpearson
    OwnerAuthor

    Research of 5 October 2026 on where a Russian egress could live. Prices were read from the providers' own pages that day; the sources are at the end.

    The finding that shapes everything: Telegram is blocked in Russia, from Russian data centres too, since March 2026.

    • OONI records the block on Rostelecom, Beeline and MTS from 20 March 2026.
    • Developers report TCP timeouts to api.telegram.org from Russian VPSs since mid-March, on Selectel and Timeweb among others.
    • Amvera's homepage states that it routes traffic to the Telegram API through a foreign IP on its users' behalf.

    So moving the whole server into Russia breaks the bot, unless the server reaches Telegram through a proxy abroad. That also affects the answer to question 3 of #301 («a host inside Russia would also be the egress #235 waits for»): it would need a proxy for Telegram.

    What fits #235 instead: keep Vercel and Neon, and send only the diary's calls through Russia.

    • Paid, recommended: a small VPS used as an HTTPS (CONNECT) proxy for dnevnik2.petersburgedu.ru only. The cheapest found is RUVDS «Старт»: 1 vCPU, 0.5 GB and IPv4 included, 149 ₽ a month, with a St Petersburg location. TLS stays end to end, so the proxy never sees the credential. Later, the v2 host (3c) could run on RUVDS «Старт HIT SSD» (1 GB, 349 ₽) with long polling and a proxy abroad for Telegram, which aiogram supports.
    • Free: a relay on Yandex Cloud Functions, whose free tier covers this traffic many times over. It needs a card on the billing account. It would see the diary token in transit, unlike a CONNECT proxy, and nobody has tested whether the diary accepts Yandex Cloud's addresses.
    • All in Russia with no proxy to run: Amvera, a PaaS that routes Telegram itself. 290 ₽ a month, or 580 ₽ with its PostgreSQL; whether its proxy passes gRPC over HTTP/2 is unchecked.

    Not verified: whether the diary accepts any of these addresses. One request from the box is the test.

    Sources (read 5 October 2026):

    • OONI: explorer.ooni.org/findings/96225549500
    • Russian Wikipedia: «Блокировка Telegram в России (2026)»
    • habr.com/ru/sandbox/288226/
    • RUVDS: ruvds.com/ru/cheap-vps/
    • Yandex Cloud free tier: yandex.cloud/ru/docs/billing/concepts/serverless-free-tier
    • Amvera: amvera.ru, docs.amvera.ru/general/price.html
  2. lumenpearson commented on Oct 5, 2026

    @lumenpearson
    OwnerAuthor

    Decided by the owner on 5 October 2026: the bot and the API stay on Vercel and Neon, and only the diary's requests go through Russia, by way of a small Russian VPS used as an HTTPS proxy.

    Next:

    • The server learns to send the Petersburg diary's requests through a proxy named by an optional setting, off by default. It is filed and built as its own pull request.
    • The owner buys the VPS and puts its proxy address into Vercel. RUVDS «Старт», 149 ₽ a month, was the cheapest that fits on 5 October.
    • One request through it to dnevnik2.petersburgedu.ru is the test that closes this issue.
  3. lumenpearson commented on Oct 5, 2026

    @lumenpearson
    OwnerAuthor

    Provider chosen by the owner on 5 October 2026: RUVDS. The cheapest plan that fits a proxy is «Старт» (1 vCPU, 0.5 GB, IPv4 included, 149 ₽ a month on 5 October), in the St Petersburg location.

  4. lumenpearson commented on Oct 5, 2026

    @lumenpearson
    OwnerAuthor

    Verified in production on 5 October 2026: the server now reaches the Petersburg diary, through the Russian proxy.

    The proxy is a RUVDS VPS (Rucloud, Korolyov) running Squid on port 23128, set up as docs/deploy.md, «The electronic diary», asks. It accepts only CONNECT to dnevnik2.petersburgedu.ru:443, and only with the password. DIARY_PROXY_URL (#334, #335) is set in Vercel for Production, Preview and Development.

    The same request was sent to production twice: POST /api/v1/diary/session for Petersburg, with a JWT-shaped session token that is not a real one.

    When Answer
    13:18 UTC, the deployment from before the variable 503, X-Diary-Unavailable: upstream, «Дневник не ответил вовремя», as on 2 October
    13:20 UTC, after the redeploy 409, «Дневник не принял эту сессию с нашего сервера — дело не в пароле.» The diary answered and refused the fake session

    At 13:20 the VPS showed both legs open: one from Vercel's function (18.185.49.10, AWS Frankfurt) into Squid, and one from Squid to 46.243.177.102:443, the city's information and analytical centre, which is the address that answered nothing from abroad on 2 October.

    Checked before production:

    • The proxy allows and refuses as intended, both from Russia and through Amsterdam:
      • with the password, the diary opens (CONNECT 200);
      • without the password, or with a wrong one, the answer is 407;
      • another host, plain HTTP and another port are each 403.
    • PetersburgClient itself reached the diary through the proxy (TCP_TUNNEL/200).
    • check-host.net opened TCP to port 23128 from Frankfurt, Nuremberg, Amsterdam, Helsinki, Los Angeles and Moscow.

    Not verified: a real family's sign-in and reads. That needs a Petersburg account, and nobody has used one with this server yet.

  5. self-assigned this
    on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

  • Status
    Done

Relationships

None yet

Development

No branches or pull requests

Issue actions