Milo OPC UA Diagnostics: Troubleshooting Null Reads

Jason IP2 min read
OPC / OPC UAOther ManufacturerTroubleshooting
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Milo SDK 0.68 can read a scalar server diagnostic with the standard client read call, but the available evidence does not establish an SDK-specific diagnostics wrapper or a confirmed session-diagnostics node. Treat the successful server-summary read and the null session result as separate cases; a null value alone does not prove that the selected node is wrong.

Confirmed server-summary read

The demonstrated Kotlin call reads a source-timestamped value with a maximum-age argument of 0.0. For Identifiers.Server_ServerDiagnostics_ServerDiagnosticsSummary_CurrentSessionCount, the returned payload is handled as UInteger.

opcUaClient.readValue(
    0.0,
    TimestampsToReturn.Source,
    nodeId
).get().value.value?.let { it as UInteger }

Why the session read remains unresolved

Applying the same scalar cast to a session-related node produces null, but the evidence does not identify the node, its declared data type, access status, or returned diagnostic metadata. The failure could involve node selection, a non-scalar value, unavailable diagnostics, or a read result without a usable payload. Do not select one cause until the complete read result is examined.

Observation Confirmed conclusion Still unknown
Server summary returns a value The shown read pattern works for the specified current-session-count node. Whether Milo provides a higher-level diagnostics API.
Session-oriented read returns null No usable payload reached the cast. Correct node, declared type, access state, and server-side availability.

Diagnostic decision procedure

  1. Retain the complete result returned by readValue; do not immediately reduce it to value.value.
  2. Record the exact session-related node selected and inspect the returned value metadata before casting.
  3. Determine whether the payload is scalar or structured and cast only to the type actually returned.
  4. Compare that result with the known-working server-summary read to separate a general client-read problem from a node-specific problem.

Using SDK types safely

The evidence supports UInteger only for the demonstrated current-session-count value. It does not establish the correct Milo type for session diagnostics. Keep the payload uncast until its declared or returned type is known; otherwise, a scalar assumption can conceal the distinction between an unavailable value and a structured diagnostic value.

FAQ

How do I read CurrentSessionCount with Milo SDK 0.68?

Call readValue(0.0, TimestampsToReturn.Source, nodeId) with Identifiers.Server_ServerDiagnostics_ServerDiagnosticsSummary_CurrentSessionCount, then handle the demonstrated payload as UInteger.

Does a null Milo session diagnostics value mean the NodeId is wrong?

No. Null confirms only that no usable payload reached the cast; inspect the complete read result, exact node, and returned type before concluding that the node is wrong.

Can I cast all OPC UA diagnostics values to UInteger?

No. The evidence supports UInteger only for the demonstrated current-session-count node. Determine whether each session diagnostic is scalar or structured before casting it.

Back to blog