Categorygithub.com/gopcua/opcua
modulepackage
0.6.4
Repository: https://github.com/gopcua/opcua.git
Documentation: pkg.go.dev

# README

Artwork by Ashley McNamara
Inspired by Renee French
Taken from https://gopherize.me by Mat Ryer

OPC/UA

A native Go implementation of the OPC/UA Binary Protocol.

We support the current and previous major Go release. See below for a list of Tested Platforms and Supported Features.

GitHub Go Reference License Version

Quickstart

# install library
go get -u github.com/gopcua/opcua

# get current date and time 'ns=0;i=2258'
go run examples/datetime/datetime.go -endpoint opc.tcp://localhost:4840

# read the server version
go run examples/read/read.go -endpoint opc.tcp://localhost:4840 -node 'ns=0;i=2261'

# get the current date time using different security and authentication modes
go run examples/crypto/*.go -endpoint opc.tcp://localhost:4840 -cert path/to/cert.pem -key path/to/key.pem -sec-policy Basic256 -sec-mode SignAndEncrypt

# checkout examples/ for more examples...

List of Breaking Changes

  • v0.6.0: The SelectEndpoint function in the client now returns an error (https://github.com/gopcua/opcua/pull/753)
  • v0.5.1: The NewClient function returns an error
  • v0.5.0: All Client methods must have a context

Sponsors

The gopcua project is sponsored by the following organizations by supporting the active committers to the project:

Northvolt evosoft Intelecy AS

Users

We would also like to list organizations which use gopcua in production:

strateos united manufacturing hub Wolfram Manufacturing Technologies IOTech System Please open a PR to include your logo here.

Projects using gopcua

gopcua is not only utilized in production environments, but it also serves as a critical component in other larger projects. Here are some projects that rely on gopcua for their functionality:

  • Telegraf: This plugin-driven server agent is used for collecting and sending metrics. It leverages gopcua to extract data from OPC-UA servers and insert it into InfluxDB. Telegraf supports both polling and subscribing methods for data acquisition.
  • benthos-umh: This project is built upon the benthos stream-processing framework. It utilizes gopcua to extract data from OPC-UA servers and forwards the information to MQTT or Kafka brokers. benthos-umh currently supports polling for data collection.

Disclaimer

We are still actively working on this project and the APIs will change.

However, you can safely assume that we are aiming to make the APIs as stable as possible since the code is in use in several large scale production environments.

The Current State was moved to the Wiki.

Your Help is Appreciated

If you are looking for ways to contribute you can

  • test the high-level client against real OPC/UA servers
  • add functions to the client or tell us which functions you need for gopcua to be useful
  • work on the security layer, server and other components
  • and last but not least, file issues, review code and write/update documentation

Also, if the library is already useful please spread the word as a motivation.

Tested Platforms

gopcua is run in production by several companies and with different equipment. The table below is an incomplete list of where and how gopcua is used to provide some guidance on the level of testing.

We would be happy if you can add your equipment to the list. Just open a PR :)

Devicegopcua versionEnvironmentBy
Siemens S7-1500v0.1.x..latestproductionNorthvolt
Beckhoff C6015-0010,C6030-0060 on OPC/UA server 4.3.xv0.1.x..latestproductionNorthvolt
Kepware 6.xv0.1.x..latestproductionNorthvolt
Kepware 6.xv0.1.x, v0.2.xproductionIntelecy
Cogent DataHub 9.xv0.1.x, v0.2.xproductionIntelecy
ABB Ability EdgeInsight 1.8.Xv0.1.x, v0.2.xproductionIntelecy
GE Digital Historian 2022 HDA Serverv0.3.xproductionIntelecy
B&R Automation PC 3100v0.3.xproductionACS
Siemens S7-1200v0.3.xCI/CD testingUMH
WAGO 750-8101v0.3.xCI/CD testingUMH
Microsoft OPC UA simulator v2.9.11v0.3.xCI/CD testingUMH
Prosys OPC UA Simulation Server v5.4.6-148v0.3.xmanual testingUMH
Edge Connect OPC-UA Serverv0.3.xproductionIOTech Systems
Siemens S7-1200v0.3.xproductionIOTech Systems
Siemens S7-1500v0.3.xproductionIOTech Systems
OMRON NX102-9020v0.3.xproductionIOTech Systems
InfluxDB Telegraf pluginv0.3.x?Community

Supported Client Features

The current focus is on the OPC UA Binary protocol over TCP. No other protocols are supported at this point.

CategoriesFeaturesSupportedNotes
EncodingOPC UA BinaryYes
OPC UA JSONnot planned
OPC UA XMLnot planned
TransportUA-TCP UA-SC UA BinaryYes
OPC UA HTTPSnot planned
SOAP-HTTP WS-SC UA Binarynot planned
SOAP-HTTP WS-SC UA XMLnot planned
SOAP-HTTP WS-SC UA XML-UA Binarynot planned
EncryptionNoneYes
Basic128Rsa15Yes
Basic256Yes
Basic256Sha256Yes
AuthenticationAnonymousYes
User Name PasswordYes
X509 CertificateYes

Supported Server Features

The current focus is on the OPC UA Binary protocol over TCP. No other protocols are supported at this point.

CategoriesFeaturesSupportedNotes
EncodingOPC UA BinaryYes
OPC UA JSONnot planned
OPC UA XMLnot planned
TransportUA-TCP UA-SC UA BinaryYes
OPC UA HTTPSnot planned
SOAP-HTTP WS-SC UA Binarynot planned
SOAP-HTTP WS-SC UA XMLnot planned
SOAP-HTTP WS-SC UA XML-UA Binarynot planned
EncryptionNoneYes
Basic128Rsa15Untested
Basic256Untested
Basic256Sha256Untested
AuthenticationAnonymousYes
User Name PasswordUntested
X509 CertificateUntested

Services

Here is the current set of supported services. For low-level access use the client Send function directly.

Service SetServiceClientServerNotes
Discovery Service SetFindServersYes
FindServersOnNetworkYes
GetEndpointsYes
RegisterServer
RegisterServer2
Secure Channel Service SetOpenSecureChannelYesYes*
CloseSecureChannelYesYes*
Session Service SetCreateSessionYesYes
CloseSessionYesYes
ActivateSessionYesYes
Cancel
Node Management Service SetAddNodes
AddReferences
DeleteNodes
DeleteReferences
View Service SetBrowseYesYes
BrowseNextYes
TranslateBrowsePathsToNodeIds
RegisterNodesYes
UnregisterNodesYes
Query Service SetQueryFirst
QueryNext
Attribute Service SetReadYesYes
WriteYesYes
HistoryReadYes
HistoryUpdate
Method Service SetCallYes
MonitoredItems Service SetCreateMonitoredItemsYesYes
DeleteMonitoredItemsYesYes
ModifyMonitoredItemsYesYes
SetMonitoringModeYesYes
SetTriggering
Subscription Service SetCreateSubscriptionYesYes
ModifySubscriptionYes
SetPublishingMode
PublishYesYes
Republish
DeleteSubscriptionsYesYes
TransferSubscriptions
  • not all encryption schemes are fully functional at this time

Authors

The Gopcua Team.

If you need to get in touch with us directly you may find us on Keybase.io but try to create an issue first.

License

MIT

# Packages

No description provided by the author
Package debug provides functions for debug logging.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Package stats provides instrumentation for the gopcua library via expvar.
No description provided by the author
Package ua defines the structures, decoders and encoder for built-in data types described in Part 6 Section 5 Data encoding and for services in OPC UA Binary Protocol.
Package uacp provides encoding/decoding and automated connection handling for the OPC UA Connection Protocol.
Package uapolicy implements the encryption, decryption, signing, and signature verifying algorithms for Security Policy profiles as defined in Part 7 of the OPC-UA specifications (version 1.04).
Package uasc provides encoding/decoding and automated secure channel and session handling for OPC UA Secure Conversation.

# Functions

ApplicationName sets the application name in the session configuration.
ApplicationURI sets the application uri in the session configuration.
ApplyConfig applies the config options to the default configuration.
AuthAnonymous sets the client's authentication X509 certificate Note: PolicyID still needs to be set outside of this method, typically through the SecurityFromEndpoint() Option.
AuthCertificate sets the client's authentication X509 certificate Note: PolicyID still needs to be set outside of this method, typically through the SecurityFromEndpoint() Option.
AuthIssuedToken sets the client's authentication data based on an externally-issued token Note: PolicyID still needs to be set outside of this method, typically through the SecurityFromEndpoint() Option.
AuthPolicyID sets the policy ID of the user identity token Note: This should only be called if you know the exact policy ID the server is expecting.
AuthPrivateKey sets the client's authentication RSA private key Note: PolicyID still needs to be set outside of this method, typically through the SecurityFromEndpoint() Option.
AuthUsername sets the client's authentication username and password Note: PolicyID still needs to be set outside of this method, typically through the SecurityFromEndpoint() Option.
AutoReconnect sets the auto reconnect state of the secure channel.
Certificate sets the client X509 certificate in the secure channel configuration.
CertificateFile sets the client X509 certificate in the secure channel configuration from the PEM or DER encoded file.
DefaultClientConfig returns the default configuration for a client to establish a secure channel.
DefaultSessionConfig returns the default configuration for a client to establish a session.
Dialer sets the uacp.Dialer to establish the connection to the server.
DialTimeout sets the timeout for establishing the UACP connection.
FindServers returns the servers known to a server or discovery server.
FindServersOnNetwork returns the servers known to a server or discovery server.
GetEndpoints returns the available endpoint descriptions for the server.
Lifetime sets the lifetime of the secure channel in milliseconds.
Locales sets the locales in the session configuration.
MaxChunkCount sets the maximum chunk count for the UACP handshake.
MaxMessageSize sets the maximum message size for the UACP handshake.
NewClient creates a new Client.
NewDialer creates a uacp.Dialer from the config options.
No description provided by the author
PrivateKey sets the RSA private key in the secure channel configuration.
PrivateKeyFile sets the RSA private key in the secure channel configuration from a PEM or DER encoded file.
ProductURI sets the product uri in the session configuration.
RandomRequestID assigns a random initial request id.
ReceiveBufferSize sets the receive buffer size for the UACP handshake.
ReconnectInterval is interval duration between each reconnection attempt.
RemoteCertificate sets the server certificate.
RemoteCertificateFile sets the server certificate from the file in PEM or DER encoding.
RequestTimeout sets the timeout for all requests over SecureChannel.
SecurityFromEndpoint sets the server-related security parameters from a chosen endpoint (received from GetEndpoints()).
SecurityMode sets the security mode for the secure channel.
SecurityModeString sets the security mode for the secure channel.
SecurityPolicy sets the security policy uri for the secure channel.
SelectEndpoint returns the endpoint with the highest security level which matches security policy and security mode.
SendBufferSize sets the send buffer size for the UACP handshake.
SessionName sets the name in the session configuration.
SessionTimeout sets the timeout in the session configuration.

# Constants

Closed, the Connection is currently closed.
Connected, the Connection is currently connected.
Connecting, the Connection is currently connecting to a server for the first time.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Disconnected, the Connection is currently disconnected.
Reconnecting, the Connection is currently attempting to reconnect to a server it was previously connected to.

# Structs

Client is a high-level client for an OPC/UA server.
Config contains all config options.
No description provided by the author
Node is a high-level object to interact with a node in the address space.
No description provided by the author
Server is a high-level OPC-UA Server.
Session is a OPC/UA session as described in Part 4, 5.6.
No description provided by the author
No description provided by the author

# Type aliases

ConnState is the ua client connection state.
Option is an option function type to modify the configuration.