opcua

package
v1.39.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 25 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidEndpoint indicates an invalid or malformed endpoint URL
	ErrInvalidEndpoint = errors.New("invalid endpoint")

	// ErrInvalidSecurityPolicy indicates an unsupported security policy
	ErrInvalidSecurityPolicy = errors.New("invalid security policy")

	// ErrInvalidSecurityMode indicates an unsupported security mode
	ErrInvalidSecurityMode = errors.New("invalid security mode")

	// ErrInvalidAuthMethod indicates an unsupported authentication method
	ErrInvalidAuthMethod = errors.New("invalid authentication method")

	// ErrCertificateGeneration indicates a failure in certificate generation
	ErrCertificateGeneration = errors.New("certificate generation failed")

	// ErrConnectionFailed indicates a connection failure
	ErrConnectionFailed = errors.New("connection failed")

	// ErrEndpointNotFound indicates no suitable endpoint was found
	ErrEndpointNotFound = errors.New("no suitable endpoint found")

	// ErrInvalidConfiguration indicates invalid configuration parameters
	ErrInvalidConfiguration = errors.New("invalid configuration")

	// ErrStatusCodeParsing indicates failure to parse status codes
	ErrStatusCodeParsing = errors.New("status code parsing failed")
)

Common OPC UA error types for better error handling and classification

Functions

This section is empty.

Types

type AddressSpaceBrowser added in v1.39.0

type AddressSpaceBrowser struct {
	Client    *opcua.Client
	Log       telegraf.Logger
	MaxDepth  int
	MaxNodes  int
	BatchSize int
}

AddressSpaceBrowser walks an OPC UA server's address space using the Browse service. Traversal is breadth-first with cycle detection; hierarchical references are followed forward, and only Object and ObjectType nodes are descended into. Variable and other terminal classes are recorded but not expanded.

MaxDepth caps the number of levels descended below the root (0 = unlimited). MaxNodes caps total discovered nodes (0 = unlimited); when reached, browsing stops and the partial result is returned. BatchSize is the number of nodes browsed per request and must be positive; callers are responsible for substituting a default.

func (*AddressSpaceBrowser) Browse added in v1.39.0

func (b *AddressSpaceBrowser) Browse(ctx context.Context, rootID *ua.NodeID) ([]*BrowsedNode, error)

Browse walks the address space starting from rootID and returns the discovered descendants. The root itself is not included in the result.

type AuthenticationError added in v1.36.0

type AuthenticationError struct {
	Method string
	Err    error
}

AuthenticationError represents an error related to authentication

func (*AuthenticationError) Error added in v1.36.0

func (e *AuthenticationError) Error() string

func (*AuthenticationError) Unwrap added in v1.36.0

func (e *AuthenticationError) Unwrap() error

type BrowsedNode added in v1.39.0

type BrowsedNode struct {
	NodeID      *ua.NodeID
	BrowseName  string
	DisplayName string
	NodeClass   ua.NodeClass
	Path        string
}

BrowsedNode is a single node discovered from the address space. Path is the slash-joined browse path from the browse root to this node, exclusive of the root itself, suitable for matching against a filter.Filter compiled with "/" as the separator.

type CertificateError added in v1.36.0

type CertificateError struct {
	Operation string
	Path      string
	Err       error
}

CertificateError represents an error related to certificate operations

func (*CertificateError) Error added in v1.36.0

func (e *CertificateError) Error() string

func (*CertificateError) Unwrap added in v1.36.0

func (e *CertificateError) Unwrap() error

type ConnectionState

type ConnectionState opcua.ConnState

func (ConnectionState) String added in v1.27.2

func (c ConnectionState) String() string

type DebugLogger added in v1.29.3

type DebugLogger struct {
	Log telegraf.Logger
}

DebugLogger logs messages from opcua at the debug level.

func (*DebugLogger) Write added in v1.29.3

func (l *DebugLogger) Write(p []byte) (n int, err error)

type EndpointError added in v1.36.0

type EndpointError struct {
	Endpoint string
	Err      error
}

EndpointError represents an error related to endpoint configuration

func (*EndpointError) Error added in v1.36.0

func (e *EndpointError) Error() string

func (*EndpointError) Unwrap added in v1.36.0

func (e *EndpointError) Unwrap() error

type OpcUAClient

type OpcUAClient struct {
	Config *OpcUAClientConfig
	Log    telegraf.Logger

	Client *opcua.Client

	// Internal flags
	DisableAutoReconnect bool
	// contains filtered or unexported fields
}

func (*OpcUAClient) Connect

func (o *OpcUAClient) Connect(ctx context.Context) error

Connect to an OPC UA device

func (*OpcUAClient) Disconnect

func (o *OpcUAClient) Disconnect(ctx context.Context) error

func (*OpcUAClient) NamespaceArray added in v1.37.0

func (o *OpcUAClient) NamespaceArray() []string

NamespaceArray returns the cached namespace array

func (*OpcUAClient) SetupOptions added in v1.25.1

func (o *OpcUAClient) SetupOptions() error

SetupOptions reads the endpoints from the specified server and sets up all authentication

func (*OpcUAClient) State

func (o *OpcUAClient) State() ConnectionState

func (*OpcUAClient) StatusCodeOK

func (o *OpcUAClient) StatusCodeOK(code ua.StatusCode) bool

func (*OpcUAClient) UpdateNamespaceArray added in v1.37.0

func (o *OpcUAClient) UpdateNamespaceArray(ctx context.Context) error

UpdateNamespaceArray fetches the namespace array from the OPC UA server The namespace array is stored at the well-known node ns=0;i=2255

type OpcUAClientConfig

type OpcUAClientConfig struct {
	Endpoint          string          `toml:"endpoint"`
	SecurityPolicy    string          `toml:"security_policy"`
	SecurityMode      string          `toml:"security_mode"`
	Certificate       string          `toml:"certificate"`
	PrivateKey        string          `toml:"private_key"`
	RemoteCertificate string          `toml:"remote_certificate"`
	Username          config.Secret   `toml:"username"`
	Password          config.Secret   `toml:"password"`
	AuthMethod        string          `toml:"auth_method"`
	ConnectTimeout    config.Duration `toml:"connect_timeout"`
	RequestTimeout    config.Duration `toml:"request_timeout"`
	ClientTrace       bool            `toml:"client_trace"`

	OptionalFields []string         `toml:"optional_fields"`
	Workarounds    OpcUAWorkarounds `toml:"workarounds"`
	SessionTimeout config.Duration  `toml:"session_timeout"`
	Locales        []string         `toml:"locales"`
}

func (*OpcUAClientConfig) CreateClient

func (o *OpcUAClientConfig) CreateClient(telegrafLogger telegraf.Logger) (*OpcUAClient, error)

func (*OpcUAClientConfig) Validate

func (o *OpcUAClientConfig) Validate() error

type OpcUAWorkarounds

type OpcUAWorkarounds struct {
	AdditionalValidStatusCodes []string `toml:"additional_valid_status_codes"`
}

type SecurityError added in v1.36.0

type SecurityError struct {
	Policy string
	Mode   string
	Err    error
}

SecurityError represents an error related to security configuration

func (*SecurityError) Error added in v1.36.0

func (e *SecurityError) Error() string

func (*SecurityError) Unwrap added in v1.36.0

func (e *SecurityError) Unwrap() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL