Skip to content
IEC 62541

OPC UA

The interoperability standard of industrial automation: a browsable address space, built-in security, and PubSub for data that fans out.

Transport
UA-TCP, WebSockets, HTTPS
PubSub
UDP, Ethernet, MQTT, AMQP
Default port
4840
Library
go-opcua
CLI
opcuactl
Interop
opcua-interop v0.19.0

OPC Unified Architecture (OPC UA) is the interoperability standard of industrial automation. A server exposes an address space: a graph of nodes (objects, variables, methods) identified by NodeIds. Clients browse that graph, read and write values, call methods, and subscribe to data changes, events and alarms, over secure channels with X.509 certificates. PubSub (Part 14) adds a second model without sessions: publishers send DataSets over UDP, Ethernet or an MQTT or AMQP broker to any number of subscribers.

Where you meet it

  • PLCs and controllers from most major vendors
  • SCADA, MES and historian servers
  • Industrial gateways that translate fieldbus protocols into a single OPC UA model
  • PubSub over MQTT or AMQP to cloud and IIoT platforms, and over UDP or Ethernet between controllers

Quickstart

From the command line

Install opcuactl with curl -fsSL https://get.otfabric.io/opcuactl | sh, or on Windows irm https://get.otfabric.io/opcuactl.ps1 | iex (all install options). No server at hand? opcuactl serve starts one with a demo address space (changing values, a writable level with an alarm, a method and history), so every command below works against opc.tcp://localhost:4840:

Terminal window
# A test server, in a second terminal
opcuactl serve
# List endpoints and their security configurations
opcuactl discover endpoints -e opc.tcp://localhost:4840
# Browse the address space
opcuactl browse children -e opc.tcp://localhost:4840
# Read a value (anonymous / None, fine for lab servers)
opcuactl get value -e opc.tcp://localhost:4840 -n i=2258
# Monitor live value changes
opcuactl monitor value -e opc.tcp://localhost:4840 -n i=2258
# List active alarms (ConditionRefresh)
opcuactl alarms list -e opc.tcp://localhost:4840
# Listen to OPC UA PubSub (UADP) on a UDP multicast group
opcuactl pubsub subscribe --url opc.udp://224.0.0.22:4840

For production servers, connect securely with endpoint auto-selection:

Terminal window
opcuactl get value -e opc.tcp://plc.example:4840 -n i=2258 \
--auth username --username operator --password "$OPCUACTL_PASSWORD" \
--security-policy auto --security-mode auto \
--cert ./pki/client.pem --key ./pki/client.key \
--trusted-cert ./pki/server-ca.pem

From Go

Terminal window
go get github.com/otfabric/go-opcua

Read the server’s current time:

main.go
package main
import (
"context"
"fmt"
"log"
"github.com/otfabric/go-opcua"
"github.com/otfabric/go-opcua/ua"
)
func main() {
ctx := context.Background()
c, err := opcua.NewClient("opc.tcp://localhost:4840")
if err != nil {
log.Fatal(err)
}
if err := c.Connect(ctx); err != nil {
log.Fatal(err)
}
defer c.Close(ctx)
v, err := c.Node(ua.MustParseNodeID("i=2258")).Value(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println("Server time:", v.Value())
}

What go-opcua supports

Roles Client and server; PubSub publisher and subscriber, standalone or inside the server
Transport UA-TCP (opc.tcp://) with reverse connect, WebSockets (opc.wss://) and HTTPS (opc.https://) with OPC UA Binary, and the UA JSON mappings of WebSockets and HTTPS (wss-uajson, https-uajson)
PubSub UADP and JSON over UDP (unicast and multicast), raw Ethernet, MQTT 3.1.1 and 5.0, and AMQP 1.0; message security with a Security Key Service; chunks, discovery and Actions
Security None, Sign and SignAndEncrypt; RSA policies from Basic128Rsa15 to Aes256Sha256RsaPss, and every ECC policy: nistP256, nistP384, brainpoolP256r1, brainpoolP384r1, curve25519 and curve448, plus the AES-GCM and ChaCha20-Poly1305 variants
Services Every client/server service set: discovery, attribute, view, method, query, node management, subscriptions and monitored items, history read and update of values and events
Beyond the services Alarms and Conditions (Part 9, with the 1.05 methods), server diagnostics, GDS certificate management by the push and pull models (Part 12), a Local Discovery Server with mDNS, NodeSet2 import
Not implemented Time-scheduled (TSN) Ethernet for PubSub
Go version 1.26 or later

Interoperability

opcua-interop runs go-opcua in every applicable client and server direction against six independent stacks: open62541 (C), Eclipse Milo (Java), async-opcua (Rust), the OPC Foundation’s UA-.NETStandard (C#), node-opcua (TypeScript) and opcua-asyncio (Python). Every peer client also manages the go-opcua server’s certificates (push model) and pulls from its Global Discovery Server, and reads, pages, filters and edits its event history. PubSub is tested against open62541 and UA-.NETStandard, and UA JSON over WebSockets and HTTPS against UA-.NETStandard, the only peer that has it. opcua-interop also publishes go-opcua as an image for others to test against. The testing page has the evidence and what is still open.

OT Fabric projects for OPC UA

go-opcua

OPC UA client and server over TCP, WebSockets and HTTPS, in UA Binary and UA JSON: RSA and ECC security, subscriptions, alarms and conditions, data and event history, GDS certificate management and PubSub.

go get github.com/otfabric/go-opcua

opcuactl

Discover, browse, read, write, call methods, monitor, handle alarms, manage certificates, read and edit history, work with OPC UA PubSub, and run a test server.

opcua-interop

OPC UA reference clients and servers: open62541, Eclipse Milo, async-opcua, UA-.NETStandard (with its GDS), node-opcua and opcua-asyncio.

Who is behind OPC UA

The organizations that publish, test, certify or host open-source work for OPC UA. Listed for reference, not as partners. Compare membership and fees.