> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OPC UA binary source

> Browse OPC UA nodes and read raw history with exact source and server timestamps.

The OPC UA app opens one UA TCP Binary session on a declared socket through
the native receiver permit. The server certificate must match the full
installed leaf pin and the application URI in the certificate. The client
uses SignAndEncrypt with `Basic256Sha256`, `Aes128_Sha256_RsaOaep`, or
`Aes256_Sha256_RsaPss`. Each observation uses a new session. The driver
supports anonymous and username/password user tokens inside that channel.

## Mount and bind

```ts app.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { app, label, secret } from "@bijectionhq/bijection";
import opcua, { opcUaEndpoint } from "@bijectionhq/app-opcua";

const plant = label();
const credential = secret();
const server = opcUaEndpoint("plant.example.com:4840", credential, plant);

export default app({ plant, credential, server, opcua: opcua({ data: plant, provider: server }) });
```

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection secret set credential --from-file opcua.json
bijection mutate opcua.source.initialize '{"selection": {"mode": "browse", "node": "i=85", "namespaceUri": "http://opcfoundation.org/UA/"}}'
```

`opcua.operator` is granted from code: `ctx.grant(opcua.operator, { to, under })` in one of your
mutations ([Grants](https://docs.bijection.com/access/grants.md)).

Set the credential to JSON with `bijection secret set`. Set `endpoint` to the
full `opc.tcp://host:port[/path]` URL with the same host and explicit port as
the receiver. Include `security_policy`, `certificate`, `private_key`,
and `server_certificate`. Supply PEM credentials and optional `username`
and `password` for a read-only identity. Configure the server to trust the
client application certificate. The full server leaf is pinned directly.
Direct TCP egress applies the deployment's address policy.

Bind the receiver and the mount under the same `data` label; the mount's
`operator` role clears it. Supply the indexed
NodeId and the URI that must occupy that namespace index on this server.

## Browse and raw history

Browse reads one node's immediate forward hierarchical references. It
publishes local references keyed by server scope and expanded NodeId.
Omissions leave prior rows in place. At most 64 references fit a browse read.

For raw history use `mode: "history"` with one canonical NodeId, its
namespace URI, `startMs`, `endMs`, and `windowSeconds`. The interval uses
absolute Unix milliseconds and is half-open. A window lasts one second to
one day. Up to 64 values fit each window. Provider continuation points
stay within the session and each observation allows up to eight result
pages, 36 KiB of output and 30 seconds. A failed window leaves its
position intact.

The raw history read requests both timestamps. Each sample includes the
source and server's original 100 ns ticks as decimal strings and their
10 ps fields as integers, with UTC text alongside them. Samples are
keyed by server scope, NodeId, source ticks and source picoseconds.
Repeated positions fail the window. A value without either timestamp
cannot land. No archive deletion is inferred. Late archive edits and
retention policy remain server behavior, so a completed range records
what the source returned across its windows. This mode uses raw history.

The archive position advances by the completed window's exclusive end.
A changed server certificate, application URI or namespace list stops a
retained position with a gap. Use the displayed source revision and gap
stamp to authorize a reset. A reset preserves prior rows.

[OPC UA historical timestamps](https://reference.opcfoundation.org/specs/OPC-10000-11/4)
[OPC UA binary DataValue encoding](https://reference.opcfoundation.org/specs/OPC-10000-6/5.2.2.17)

## Monitored items

Use `{ mode: "subscription", node, namespaceUri, windowSeconds }` to
observe one Value monitored item for one to ten seconds per poll. Use one
mount per node. Both timestamps and their picosecond fields are retained
when the server supplies them. Each sample includes its notification
sequence, ordinal, and whether Republish recovered it.

The driver tries to replay up to eight missing notification messages before
accepting later messages in that session. Overflow or a missing message
outside the server's retransmission queue stops the retained source
position. A single window admits up to 64 values, 32 Publish responses,
and 36 KiB of output. The app keys samples by provider scope, node, window,
sequence, and ordinal. It publishes observations without deleting prior rows.

The cursor records the last observation window and its server scope. Each
poll opens its own subscription. Values between windows and across lost
sessions can be absent. Use raw history to read archive coverage across
those intervals.

[OPC UA Publish and Republish](https://reference.opcfoundation.org/specs/OPC-10000-4/5.14)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.