Skip to content

feat(rbn): Reduce network traffic from the Reverse Beacon Network - #1187

Open
n7wlc wants to merge 1 commit into
accius:Stagingfrom
n7wlc:Staging
Open

n7wlc wants to merge 1 commit into
accius:Stagingfrom
n7wlc:Staging

Conversation

@n7wlc

@n7wlc n7wlc commented Sep 13, 2026

Copy link
Copy Markdown

The connection to RBN produces about 6 spots/second. If the user (client side) has not enabled the RBN, the server processes these spots even though the information is never used.

Now the RBN connection is not made until the first request comes in from the client. The connection is maintained until 5 minutes after the last request. At that point the connection is closed. Spot cleanup continues normally.

What does this PR do?

see above

Type of change

  • Bug fix
  • New feature
  • Performance improvement
  • Refactor / code cleanup
  • Documentation
  • Translation
  • Map layer plugin

How to test

  1. Comment out line 80 in server.js ("installRateLimiter();")
  2. Start the server: npm run start
  3. Start the client.
  4. Observe server log: No lines with "[RBN]" until after it is enabled in the client.
    Note: There are no changes to the client code. Only server/routes/rbn.js

Checklist

  • App loads without console errors
  • Tested in Dark, Light, and Retro themes
  • Responsive at different screen sizes (desktop + mobile)
  • If touching server.js: caches have TTLs and size caps (we serve 2,000+ concurrent users)
  • If adding an API route: includes caching and error handling
  • If adding a panel: wired into Modern, Classic, and Dockable layouts
  • No hardcoded colors — uses CSS variables (var(--accent-cyan), etc.)
  • No .bak, .old, console.log debug lines, or test scripts included

The connection to RBN produces about 6 spots/second.  If the user
(client side) has not enabled the RBN, the server processes these
spots even though the information is never used.

Now the RBN connection is not made until the first request comes in
from the client.  The connection is maintained until 5 minutes after
the last request.  At that point the connection is closed.  Spot
cleanup continues normally.

@accius accius left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this — the goal is a good one. ~6 spots/s of parsing and map churn for a feed nobody is looking at is real work on a Pi 3, and the change itself is small and readable. CI is green (format, JSON keys, Node 22 tests) and it applies cleanly to Staging.

I can't merge it as written, though, because the RBN stream isn't only consumed by the two /api/rbn/* endpoints — it's a shared server-side data source, and this PR changes that contract without the other consumers knowing.

Blocking

1. Band Openings goes dark. server/routes/band-openings.js reads ctx.rbnSpotsByDX directly from a 60 s background sampler to build its 3 h baseline — no client request involved (its header comment says the RBN cache "fills autonomously"). With this PR the map only fills while someone has the RBN layer, the RBN panel, or the IBP panel open. On a self-hosted install Band Openings would sit in a permanent warming state or show cluster-derived openings only. The test plan only watches for [RBN] log lines, so this wouldn't have shown up.

2. /api/health reports RBN as down for most self-hosters. checkRbn() in server/health.js returns down whenever the socket isn't connected, and this PR makes "not connected" the normal idle state. Anyone who never uses RBN gets a permanently degraded health endpoint. (The hosted site is unaffected — someone is always polling — and watchtower reads the same field, so it wouldn't alert there either.)

Worth knowing

3. Cold-start gap. Today the server always holds 30 min of history, so enabling RBN shows spots immediately. With lazy connect, the first request opens the socket and the panel is empty until spots accumulate — roughly the length of the chosen window. Never happens on the hosted site; on a single-user install it's visible the first time RBN is turned on after a quiet spell.

4. Minor. The error handler still reconnects unconditionally, so an idle connection that errors (rather than closes) comes back and idles out again — inconsistent with the intent. And I'd remove the commented-out maintainRBNConnection(7000) rather than leave it.

What I'd like to see

Any of these would get it over the line:

  • Keep lazy connect, but make Band Openings a consumer too. Export a small touch()/ensureConnected() from rbn.js and have the band-openings sampler call it (or drive the idle timer from any reader of the spot map, not just the HTTP routes).
  • Teach health the difference between "idle by design" and "down". Report ok with a detail like idle — no RBN consumers in the last 5 min when nothing has asked for spots within the TTL, and only down when a consumer wanted it and the socket isn't up.
  • Or gate the whole thing behind an env flag — e.g. RBN_LAZY_CONNECT=true, default off — so the hosted instance and existing installs keep today's behaviour while Pi users opt in. That also sidesteps the cold-start gap for everyone who didn't ask for it.

Happy to help with whichever direction you prefer. 73 de K0CJH

@n7wlc

n7wlc commented Sep 14, 2026 via email

Copy link
Copy Markdown
Author

@n7wlc

n7wlc commented Sep 17, 2026 via email

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants