OPC UA Server

This page describes how the Connectware can act as an OPC UA server. The Connectware can also act as a OPC UA client.

To run an OPC UA server, the commissioning file must contain a server resource of type Cybus::Server::Opcua. This will start an OPC UA server that can be accessed by OPC UA clients. From the OPC UA client, this server is reachable by the following address:

opc.tcp://<connectwareHost>:4841<resourcePath>

Note: The OPC UA server provided by the Connectware uses the non-standard port number 4841 (whereas standard OPC UA uses port 4840) in order to avoid port number collisions on computers where another OPC UA server is already running. Also note: The Connectware can run exactly one instance of an OPC UA server, not multiple instances.

If your Connectware instance is running on a system that is reachable by a DNS hostname, this hostname must be specified in the hostname property, so that the server is reachable from outside of the Connectware docker network. The value localhost is not valid in this case, as localhost refers to the local Docker container but not the host itself, which means this name is not reachable from other containers or the host system.

Additionally, the property resourcePath is important when when connecting to the OPC UA server. This property defines the prefix of the connection string and defaults to the value /UA/CybusOpcuaServer. Please note that this string has to be added to the URL when connecting from a client to the OPC UA Server. Otherwise the client might not be able to connect successfully.

The server configuration is specified by the properties of the server resource. The actual data points (nodes in OPC UA) are specified by defining resources of type Cybus::Node::Opcua, one resource for each node. The nodes are structured in a tree-like hierarchy. There must be exactly one root node, which has its parent property set as a reference to the server object. All other nodes reference either the root node or other intermediate nodes as parent, forming a tree of nodes on the OPC UA Server.

Nodes can be defined within the same service as the OPC UA server, or also in other services using inter-service referencing using the service-id. It is thus possible to add or remove nodes while the OPC UA server is running, by adding more service commissioning files.

Custom Server Properties

port (integer)

Port of the listening socket

Default: 4841

Example: 4841

maxSessions (integer)

Max Sessions allowed by user

Default: 20

Example: 1000

maxConnections (integer)

Max Connections allowed for a single endpoint to prevent DDoS attacks

Default: 20

Example: 1000

resourcePath (string)

Resource Path of the OPC Server. This must be added to the OPC UA connection URN of the client

Default: "/UA/CybusOpcuaServer"

Examples: "/UA/CybusOpcuaServer", "/My/IndividualName"

alternateHostname (string)

This setting is deprecated, has been renamed into ‘hostname’, and will be removed in a future release

Examples: "10.20.30.40", "my.connectware-host.company.com"

hostname (string)

The hostname by which the Connectware with the OPC UA server will be reachable on the system. This can be either an IP address or a DNS name.

Examples: "10.20.30.40", "my.connectware-host.company.com"

applicationUri (string)

The application URI is used to define the namespace name of the Connectware defined NodeIds

Default: "urn:cybus:opcua:server:1"

Example: "urn:cybus:opcua:server:1"

allowAnonymous (boolean)

If true, usage of anonymous access token is allowed. In that case, OPC UA clients are allowed to connect without any authentication. Note: This is a high security risk and must not be used in production deployments.

Default: false

Example: true

certificateFile (string)

Absolute path to the server certificate file

Default: "/connectware_certs/cybus_server.crt"

Example: "/connectware_certs/cybus_server.crt"

privateKeyFile (string)

Absolute path to the server private key file

Default: "/connectware_certs/cybus_server.key"

Example: "/connectware_certs/cybus_server.key"

securityPolicies (array)

Defines the list of OPC UA securityPolicies that will be available on the server. Note: The policy “None” is a high security risk and must not be used in production deployments.

The object is an array with all elements of the type string.

Each element of the array must be one of the following enum values:

  • Basic256Sha256

  • None

Default:

[
  "Basic256Sha256"
]

Example: "[\"Basic256Sha256\", \"None\"]"

nodesetFiles (array)

Predefined Nodeset files to load on startup

The object is an array with all elements of the type string.

Each element of the array must be one of the following enum values:

  • standard

  • di

  • ia

  • machinery

  • machineTool

  • packML

  • robotics

  • Opc.Ua.PlasticsRubber.GeneralTypes.NodeSet2.xml

  • Opc.Ua.PlasticsRubber.IMM2MES.NodeSet2.xml

  • Opc.Ua.PLCopen.NodeSet2.xml

securityModes (array)

Defines the list of OPC UA security modes which an OPC client can use to establish a connection to the Cybus OPC UA server

The object is an array with all elements of the type string.

Each element of the array must be one of the following enum values:

  • Invalid

  • None

  • Sign

  • SignAndEncrypt

Default:

[
  "SignAndEncrypt"
]

Example: "[\"None\", \"SignAndEncrypt\"]"

database (object)

Definition of the database for historical access of the data. If this property exists, historical access is enabled, otherwise it is not enabled.

Properties of the database object:

type (string, enum)

Type of the history database

This element must be one of the following enum values:

  • influx

Default: "influx"

Example: "influx"

host (string)

Database Host

Example: "10.20.30.40"

port (integer)

Port of the database server

Default: 8086

Example: 8086

name (string)

Database Name

Example: "opcuaHistory"

retention (integer)

Data older than the specified number of days will be automatically discarded

Example: 356

Custom Node Properties

browseName (string, required)

The browse name (not path) of this node

Examples: "temperature1", "pressure2"

nodeId (string)

The specific node id of this node

Example: "ns=1;s=spindleSpeed"

nodeType (string, enum, required)

The node type: Whether this node is a variable or an object.

This element must be one of the following enum values:

  • Object

  • Variable

historize (boolean)

Whether to accumulate an historian for this node

Default: false

interpolation (string, enum)

The displayed interpolation mode

This element must be one of the following enum values:

  • stepped

  • sloped

Default: "sloped"

maxTimeInterval (integer)

Specifies the maximum interval between data points in the history repository regardless of their value change [in milliseconds]

Default: 10000

Example: 1000

minTimeInterval (integer)

Specifies the minimum interval between data points in the history repository regardless of their value change [in milliseconds]

Default: 500

Example: 100

dataType (string)

The data type of this node. This can be either an OPC UA base type (see example values), or a node ID which references a data type node.

Examples: "Boolean", "Byte", "ByteString", "DataValue", "DateTime", "DiagnosticInfo", "Double", "ExpandedNodeId", "ExtensionObject", "Float", "Guid", "Int16", "Int32", "Int64", "LocalizedText", "NodeId", "Null", "QualifiedName", "SByte", "StatusCode", "String", "UInt16", "UInt32", "UInt64", "Variant", "XmlElement"

serializeDataType (string, enum)

For nodes where the data type is not an OPC UA base type but a node reference, the data type for serialization of values sometimes needs to be specified separately here. This must be a basic OPC UA data type.

This element must be one of the following enum values:

  • Boolean

  • Byte

  • ByteString

  • DataValue

  • DateTime

  • DiagnosticInfo

  • Double

  • ExpandedNodeId

  • ExtensionObject

  • Float

  • Guid

  • Int16

  • Int32

  • Int64

  • LocalizedText

  • NodeId

  • Null

  • QualifiedName

  • SByte

  • StatusCode

  • String

  • UInt16

  • UInt32

  • UInt64

  • Variant

  • XmlElement

valueRank (integer, enum)

The rank of the transported data, default is scalar (-1), use 1 for array of scalars

This element must be one of the following enum values:

  • -3

  • -2

  • -1

  • 0

  • 1

  • 2

Default: -1

arrayDimensions (array)

For nodes that represent an array or a multi-dimensional array (e.g. a matrix), this array value specifies the size in each of the dimensions.

The object is an array with all elements of the type number.

Example: [6,4]

Example Commissioning File

Download: opcua-server-example.yml

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
---
description: >

  This is a fixture showing server resource functionality

metadata:

  name: OPC UA Server example
  version: 1.0.0
  icon: https://www.cybus.io/wp-content/uploads/2017/10/for-whom1.svg
  provider: cybus
  homepage: https://www.cybus.io

parameters:

  influxPort:
    type: integer
    default: 8086
    title: Influx Database Port

  retentionTime:
    type: integer
    default: 356
    title: Retention Time

definitions:

  databaseName: opcuaHistory

resources:

  influxdb:
    type: Cybus::Container
    properties:
      image: influxdb:1.8-alpine
      ports:
        - !sub '${influxPort}:8086/tcp'
      volumes:
        - !sub '${influxdbVolume}:/var/lib/influxdb'
      environment:
        INFLUXDB_DB: !ref databaseName
        INFLUXDB_HTTP_FLUX_ENABLED: true

  influxdbVolume:
    type: Cybus::Volume

  opcuaServer:
    type: Cybus::Server::Opcua
    properties:
      database:
        host: 172.17.0.1
        name: !ref databaseName
        retention: !ref retentionTime
      allowAnonymous: false
      certificateFile: /connectware_certs/cybus_server.crt
      privateKeyFile: /connectware_certs/cybus_server.key

  parentNodeRoot:
    type: Cybus::Node::Opcua
    properties:
      browseName: parentNodeRoot
      nodeId: ns=1;s=parentNodeRoot
      parent: !ref opcuaServer
      nodeType: Object

  parentNode1:
    type: Cybus::Node::Opcua
    properties:
      browseName: parentNode1
      nodeId: ns=1;s=parentNode1
      parent: !ref parentNodeRoot
      nodeType: Object

  parentNode2a:
    type: Cybus::Node::Opcua
    properties:
      browseName: parentNode2a
      nodeId: ns=1;s=parentNode2a
      parent: !ref parentNode1
      nodeType: Object

  parentNode2b:
    type: Cybus::Node::Opcua
    properties:
      browseName: parentNode2b
      nodeId: ns=1;s=parentNode2b
      parent: !ref parentNode1
      nodeType: Object

  dataNodeRoot1:
    type: Cybus::Node::Opcua
    properties:
      browseName: dataNodeRoot1
      nodeId: ns=1;s=dataNodeRoot1
      parent: !ref parentNodeRoot
      nodeType: Variable
      operation: serverProvides
      dataType: Boolean

  dataNodeRoot2:
    type: Cybus::Node::Opcua
    properties:
      browseName: dataNodeRoot2
      nodeId: ns=1;s=dataNodeRoot2
      parent: !ref parentNodeRoot
      nodeType: Variable
      operation: serverReceives
      dataType: DateTime

  dataNodeRoot3:
    type: Cybus::Node::Opcua
    properties:
      browseName: dataNodeRoot3
      nodeId: ns=1;s=dataNodeRoot3
      parent: !ref parentNodeRoot
      nodeType: Variable
      initialValue: 42.0
      operation: serverProvidesAndReceives
      dataType: Float
      historize: true

  dataNode1:
    type: Cybus::Node::Opcua
    properties:
      browseName: dataNode1
      nodeId: ns=1;s=dataNode1
      parent: !ref parentNode1
      nodeType: Variable
      operation: serverReceives
      dataType: Int32

  dataNode2a:
    type: Cybus::Node::Opcua
    properties:
      browseName: dataNode2a
      nodeId: ns=1;s=dataNode2a
      parent: !ref parentNode2a
      nodeType: Variable
      operation: serverProvides
      dataType: Double
      historize: true

  dataNode2b:
    type: Cybus::Node::Opcua
    properties:
      browseName: dataNode2b
      nodeId: ns=1;s=dataNode2b
      parent: !ref parentNode2b
      nodeType: Variable
      operation: serverProvides
      dataType: String

  mapping:
    type: Cybus::Mapping
    properties:
      mappings:
        - publish:
            topic: my/opcuaData/dataNode1
          subscribe:
            endpoint: !ref dataNode1

        - publish:
            endpoint: !ref dataNode2a
          subscribe:
            topic: my/opcuaData/dataNode2a

Output Format

If the server receives data from an external OPC UA client, the output on the internal MQTT broker will be provided as JSON object:

{
  "timestamp": "<unix timestamp in ms>",
  "value": "value"
}

Input Format

If the server should provide data to an external OPC UA client, the message on the internal MQTT broker must be published in this format:

{
  "value": "<value>"
}

Note: If 64-bit integers are being used (which are unsupported in JSON, but are supported in Javascript by the BigInt class), the value must be given as a string that contains the decimal number.