Skip to content

Backend keeps serving a stale/factory-less EdgeConfig → all component settings forms render blank, with no self-heal until the Edge is restarted #3756

Description

@cvabc

Description

On an Edge that is online with live data, the UI can show every component's Update Component form blank and the Install Component factory list empty. It stays that way until the Edge process is restarted.

Root cause is a one-way, fire-and-forget config sync with no reconcile:

  1. The UI's getEdgeConfig is answered by the Backend from its cached EdgeConfig (EdgeRpcRequestHandler#handleGetEdgeConfigRequest → metadata.edge().getEdgeConfig(edgeId)).
  2. That cache is updated only when the Edge pushes an EdgeConfigNotification — fire-and-forget on websocket (re)connect (OnOpen) and on config change. No result check, no periodic re-send, no Backend re-request.
  3. The auto-reconnect (ClientReconnectorWorker, reset() + connectBlocking()) does not reliably fire the org.java_websocket onOpen callback. Config is only re-pushed from inside onOpen → on a missed onOpen, the Edge never re-pushes.
  4. Telemetry has its own retry (SendChannelValuesWorker) and keeps flowing → Edge stays online with a factory-less Backend config.
  5. UI builds forms from factory.properties; with no factories it renders blank — no self-heal until the Edge restarts.

Possible fix:

Re-request getEdgeConfig when cache is empty/incomplete and Edge online

 public class EdgeRpcRequestHandler {
@@ -503,6 +506,26 @@ public class EdgeRpcRequestHandler {
                        GetEdgeConfigRequest request) throws OpenemsNamedException {
                var config = this.parent.metadata.edge().getEdgeConfig(edgeId);

+               // Self-heal: if the cached config lost its factory catalog (-> UI settings
+               // forms render blank) but the Edge is online, pull the live config from the
+               // Edge instead of serving the stale cache, and refresh the cache so the next
+               // reads hit it and other consumers see it too. getEdgeConfig is reachable on
+               // the Edge via componentJsonApi -> "_componentManager".
+               if (config.getFactories().isEmpty()
+                               && this.parent.metadata.getEdge(edgeId).map(e -> e.isOnline()).orElse(false)) {
+                       return this.parent.edgeManager.send(edgeId, user,
+                                       new ComponentJsonApiRequest("_componentManager", request)) //
+                                       .thenApply(response -> {
+                                               var live = EdgeConfig.fromJson(response.getResult());
+                                               this.parent.metadata.getEdge(edgeId).ifPresent(edge -> EventBuilder
+                                                               .from(this.parent.eventAdmin, Edge.Events.ON_SET_CONFIG) //
+                                                               .addArg(Edge.Events.OnSetConfig.EDGE, edge) //
+                                                               .addArg(Edge.Events.OnSetConfig.CONFIG, live) //
+                                                               .send());
+                                               return new GetEdgeConfigResponse(request.getId(), live);
+                                       });
+               }
+
                // JSON-RPC response
                return CompletableFuture.completedFuture(new GetEdgeConfigResponse(request.getId(), config));
        }

Screenshots

No response

Operating System

Ubuntu 24.04

How to reproduce the Error?

Natural occurrence is intermittent — cannot be reproduced deterministically on a clean loopback (there reconnect reliably fires onOpen). Field-correlated with 1006/1008 close codes.

Deterministic repro (host-run Edge+Backend, Metadata.Dummy):

  1. Start Backend → Edge; confirm a settings form renders.
  2. Restart Backend (comes up with empty config cache).
  3. Let Edge reconnect; telemetry resumes but onOpen may not fire (suppress OnOpenHandler dispatch on reconnect to force it deterministically).
  4. UI settings page → all forms blank / factory list empty, Edge still online.
  5. Restart Edge → config re-pushed, forms render again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions