meshmonitor icon indicating copy to clipboard operation
meshmonitor copied to clipboard

http connection drops

Open mchoff opened this issue 6 months ago • 13 comments

version 4.5.2 docker compose

using wifi node (heltec v4). doesn't hold a consistent HTTP connection to meshmonitor About every 1-2 minutes getting this error: Connection Error Cannot connect to Meshtastic node at Loading.... Please ensure the node is reachable and has HTTP API enabled.

Continuous ping to node fine, no drops. board doesn't reset, good power, good wifi signal. Its physically on my desk for testing. Meshmonitor will reconnect to it momentarily and repeats. Other clients i have used seem to hold connection fine.

from docker log - node disconnect notification sent from source is about the only thing i can find.

[INFO] Node disconnect notification sent for source e1c0ee11-78fe-4f41-8bf1-e6bf16c8193d [INFO] ⚠️ No device config available yet - returning null [INFO] [WebSocket] Client disconnected: uqJdPZoBBZBCWoJbAAAl (reason: transport close) [INFO] ⚠️ No device config available yet - returning null [INFO] [DataEventEmitter] Connection status: connected

any suggestions where to look? thx!

mchoff avatar May 16 '26 17:05 mchoff

Thanks for the detailed report — this is a known pattern with WiFi-capable Meshtastic nodes (Heltec V4 and similar).

Root cause

WiFi node firmware (and home router/AP connection-tracking tables) typically close idle TCP sessions after roughly 60–120 s of silence. MeshMonitor had an application-level heartbeat feature (ToRadio.heartbeat) introduced in #2609 to prevent exactly this, but it defaulted to disabled (heartbeatIntervalSeconds = 0). Any source without an explicit setting would therefore experience regular drops at whatever the firmware's idle timeout happens to be — matching your 1–2 minute pattern.

The OS-level TCP keepalive was set to 5 minutes, which is too long to prevent the firmware-side timeout from firing first.

Fix (in branch claude/great-dijkstra-GPT1r)

Three changes:

  1. meshtasticManager.ts — default heartbeat changed from 0 (disabled) to 30 seconds for all TCP sources without an explicit setting. Every 30 s MeshMonitor sends a ToRadio.heartbeat; the node replies with FromRadio.queueStatus, refreshing the idle timer on both sides. To explicitly disable, set heartbeatIntervalSeconds = 0 in the source settings.

  2. DashboardPage.tsx — the source save form now always persists heartbeatIntervalSeconds (including 0), so a deliberate "disable" sticks instead of being silently dropped.

  3. App.tsx — cosmetic fix: the "Cannot connect to Meshtastic node at Loading..." error message no longer shows the Loading... placeholder when the config hasn't loaded yet.

Workaround until next release

If you want to apply a fix immediately without waiting for the next release: open the source settings for your Heltec V4 source in the dashboard and set Heartbeat Interval to 30 seconds, then save. This has the same effect as the default change above.


Generated by Claude Code

Yeraze avatar May 16 '26 17:05 Yeraze

All better now?

Yeraze avatar May 17 '26 01:05 Yeraze

All better now?

Nope, tried 20 sec, doesn't fix it. My node has no wifi issues with android client. Went back to meshmonitor 4.3.2 docker, everything works again.

jujulechti avatar May 17 '26 14:05 jujulechti

Image

Is it possible that tcp session fails because the node is overwhelmed by config load requests coming from meshmonitor ?

jujulechti avatar May 17 '26 14:05 jujulechti

Thanks for sticking with this. I went and diffed v4.3.2..v4.5.2 to chase your overwhelm hypothesis directly, and the diff actually doesn't support it — src/server/meshtasticManager.ts, src/server/tcpTransport.ts, and src/server/sourceManagerRegistry.ts have no changes to the outbound-packet pipeline, the post-connect scheduler, or reconnect logic. The requestAllModuleConfigs burst is still gated by moduleConfigsEverFetched (it does not replay on reconnect), heartbeat defaults to 0 in both versions, and the embedded MQTT broker that could have added outbound traffic only landed on main after v4.5.2 — it isn't in the image you're running. So before we change anything, I want to verify the hypothesis rather than assume it.

One artifact would unblock this: from a cold start of the v4.5.2 container, please capture container logs through the second TCP drop (~3–4 minutes total) and attach the file:

docker logs <container-name> 2>&1 > meshmonitor-4.5.2-drops.log

That gives me three things in one shot:

  1. Outbound packet rate per minute — confirms or kills the "overwhelmed" theory.
  2. Whether your heartbeatIntervalSeconds=20 is actually producing heartbeat frames at 20 s, or whether the UI value isn't propagating to the live manager.
  3. The exact disconnect cause (FIN vs RST vs ECONNRESET vs transport-close) from the transport's 'close'/'error' event.

If you can grab the equivalent ~3 minutes on v4.3.2 as a baseline, that's even better — it lets me compare per-minute outbound-packet counts directly. Also, while you're in the UI: a screenshot of your Settings → Connection page showing the heartbeat value and the auto-traceroute / time-sync / local-stats / announce intervals would help me rule out a settings-migration drift from the upgrade.

Yeraze avatar May 17 '26 15:05 Yeraze

here is with 4.2.3 : https://dpaste.com/7EWL72GD2 (sorry for the length, i didn't mange to capture only one start)

jujulechti avatar May 17 '26 16:05 jujulechti

here is with 4.5.2 : https://dpaste.com/BQ82F4Z6C

EDIT: Can't explain, now it works, no more disconnections ...

jujulechti avatar May 17 '26 16:05 jujulechti

Thanks — both captures are very useful. A couple of observations from the logs before I read too much into them:

  • I do see your heartbeatIntervalSeconds=20 setting taking effect on v4.5.2 (💓 Heartbeat enabled for source 4649000c-… : every 20s near the top of the v4.5.2 log), so the UI value is propagating to the manager correctly.
  • I notice MESHTASTIC_NODE_IP=82.65.31.180 in both logs — that's a public IP rather than a LAN address, so the TCP session is traversing your router/ISP rather than staying inside the LAN. That's relevant because the classic "1–2 minute drop" cadence on a remote TCP session is almost always a NAT or stateful-firewall connection-tracking entry timing out idle.

Two questions before I draw any conclusions, because they'd change the diagnosis materially:

  1. Is anything else also connected to this Heltec at the same time (e.g. the Meshtastic Android/iOS app, another MeshMonitor instance, meshtastic-cli, an MQTT proxy, anything that holds a TCP session on 82.65.31.180:4403)? Meshtastic firmware will rotate clients aggressively when a second one shows up, which mimics a 1–2 min flap on the first.
  2. Is the Heltec on the same LAN as the MeshMonitor host, or do you have to reach it through your router/ISP from outside? If it's actually local, can you try setting MESHTASTIC_NODE_IP to the LAN address and confirming whether that changes the behaviour?

I'm asking before showing my read of the two logs because if either of those is in play, the answer's not in the code at all and we'll need to look at network state instead.

Yeraze avatar May 17 '26 16:05 Yeraze

My node is not on the the same lan as my meshmonitor instance, they are not in the same building , all my IP's are static and my port forwarding is set, all without NAT.

jujulechti avatar May 17 '26 17:05 jujulechti

All better now?

YES although I’m a little embarrassed as to why. The stupid little ribbed antenna that comes with the unit. I thought was for Lora but nooooo that’s the wifi ble antenna. I had a Lora whip anyway. Originally I had an old wifi antenna from old pc guts I was connecting to heltec wifi antenna spot. When I put the ribbed one that comes with it, Problem vanished immediately. Kind of baffled that pings(ip) were not dropping at all, good signal and latency on both antennas. Unless it’s a coincidence that stupid little antenna fixed my issue. I set heartbeat initially but didn’t fix my problem until the WiFi antenna swap.

mchoff avatar May 17 '26 17:05 mchoff

Got it on the topology — node remote, static IPs, port-forwarded.

Important finding from the two captures: this isn't a 4.5.2 regression. Your v4.3.2 log — the one where "everything works again" — is flapping at the same cadence as the v4.5.2 log. Both show a fresh device-config burst every ~290 log lines, which means MeshMonitor is reconnecting just as often on the version you consider working as on the version you consider broken:

v4.3.2 capture v4.5.2 capture
📊 Raw Device config from device (= one full reconnect each) 30 3
Lines per reconnect cycle ~260–320 ~290
Capture length 9453 lines 909 lines
Heartbeat enabled for source default (would mean a second TCP session) never (default is a phantom source, no TCP) n/a (4.x migration consolidated to one source)

The v4.3.2 capture is just ~10× longer in real time, so it caught 30 reconnect cycles where the v4.5.2 capture caught 3. The TCP session is dropping every ~1–2 minutes on both versions — v4.3.2 was flapping silently and the 4.x line just makes it visible to you via the connection-error overlay and the Apprise / WebSocket server-event notifications added during the multi-source rewrite.

Code-side confirmation: git diff v4.3.2..v4.5.2 -- src/server/meshtasticManager.ts src/server/tcpTransport.ts src/server/sourceManagerRegistry.ts shows no changes to the outbound-packet pipeline, reconnect logic, or transport settings between the two tags. The cause is below MeshMonitor.

So we're not chasing a regression; we're chasing whatever has always been kicking your TCP session. A couple of quick follow-ups to pin it down:

  1. (re-asking my earlier Q1 because it's load-bearing now) Is anything else opening a TCP session to 82.65.31.180:4403 while MeshMonitor is running — the Meshtastic Android/iOS app on your phone, meshtastic-cli, an MQTT proxy at the node's end, a second MeshMonitor? Meshtastic firmware accepts only one TCP client at a time and will kick whichever one was connected when a new one arrives, producing exactly this flap pattern. From your MeshMonitor host: ss -tn dst 82.65.31.180. From elsewhere on the path: meshtastic --host 82.65.31.180 --info right after seeing a drop will tell us if something else also has a session.
  2. Stateful-firewall idle timeout in the path. Even with no NAT, any stateful firewall (on either end's router, your ISP's edge, or a hop in between) typically times out idle TCP at 60–120 s. The encrypted protobuf heartbeat may not refresh that table entry.
  3. Worth trying: drop heartbeatIntervalSeconds to 10 and check whether the flap cadence widens. If 10 s fixes it but 20 s didn't, a stateful-firewall idle threshold is the culprit. If 10 s doesn't help either, the heartbeats aren't reaching the device.

If a parallel client is the cause, the fix is to close the other client or route it through MeshMonitor's MQTT proxy. If it's a path timeout, a 10 s heartbeat should fix it.

Yeraze avatar May 17 '26 17:05 Yeraze

All better now?

YES although I’m a little embarrassed as to why. The stupid little ribbed antenna that comes with the unit. I thought was for Lora but nooooo that’s the wifi ble antenna. I had a Lora whip anyway. Originally I had an old wifi antenna from old pc guts I was connecting to heltec wifi antenna spot. When I put the ribbed one that comes with it, Problem vanished immediately. Kind of baffled that pings(ip) were not dropping at all, good signal and latency on both antennas. Unless it’s a coincidence that stupid little antenna fixed my issue. I set heartbeat initially but didn’t fix my problem until the WiFi antenna swap.

I've made that same mistake myself :) Glad it's sorted.

Yeraze avatar May 17 '26 17:05 Yeraze

Hi, heartbeatIntervalSeconds seems to be the sweet spot, only 1 connexion loss for 12+ hours. It seems to be an issue with my ISP as you said. I had connexion drops issues every 1-2 hours since a few months, i think that firmware and meshmonitor update reducing useless packets exchange made the ISP issue more visible. Before, it was very rare to have 20 seconds without tcp exchange between node and meshmonitor, with recent optimizations, there is much less tcp traffic. In France, ISPs subscriptions are very cheap, we have fiber everywhere, i personally have Static Full Stack IPv4 included in my 2 simple residential plans. (they put a disclaimer when you enable static full stack ipv4 like it is a pro advanced feature, you should not enable it ... no, it just cost them precious ipv4, otherwise, they split port range in 4 to use 1 ip for 4 subscribers.) So to be that cost efficient, they cut corners, like on peering with cdn like netflix and youtube, they don't want to pay for more peering capacity so the customer get slow loading times and lots of packet loss. For meshmonitor users using public node IPs, that means i have to work with the aggressive tcp QOS management of my ISP. (I have a network and telecommunications degree, so tcp session getting killed after 30 seconds by my ISP QOS management doesn't surprise me that much) Maybe i can check this out on WireShark on my side ? Would it be possible to add a popup or disclaimer in meshmonitor when it detects lots of tcp connection with a public node IP in place ? Like : "Meshmonitor detects lots of connection drop and you are using a public node IP : 1)Check if your node is stable via usb, or Bluetooth 2)Check if your node works correctly via wifi with your smartphone or web client. 3) Try lowering heartbeatIntervalSeconds to ensure that your ISP is not aggressively shutting down tcp sessions or resetting routing to save on backbone network load. So my node config had a hard time loading because it tried to use an already ungracefully terminated tcp session because of my ISP QOS management ?

jujulechti avatar May 18 '26 07:05 jujulechti