Figure 12illustrates the structure of a Messageplaced on the wire. This also illustrates how the Messageelements defined by the OPC UA Binary Encoding mapping (see 5.2) and the OPC UA Secure Conversation mapping (see 6.7) relate to the OPC UA Connection Protocol Messages.

image015.png

Figure 12– OPC UA Connection Protocol Message structure

Every OPC UA Connection Protocol Messagehas a header with the fields defined in Table 50.

Table 50– OPC UA Connection Protocol Message header

Name

Type

Description

MessageType

Byte [3]

A three byte ASCII code that identifies the Messagetype.

The following values are defined at this time:

HEL a Hello Message.

ACK an Acknowledge Message.

ERR an Error Message.

RHE a ReverseHello Message.

The SecureChannellayer defines additional values which the OPC UA Connection Protocollayer shall accept.

Reserved

Byte [1]

Ignored. shall be set to the ASCII codes for ‘F’ if the MessageTypeis one of the values supported by the OPC UA Connection Protocolprotocol.

MessageSize

UInt32

The length of the Message, in bytes. This value includes the 8 bytes for the Messageheader.

The layout of the OPC UA Connection Protocol Messageheader is intentionally identical to the first 8 bytes of the OPC UA Secure Conversation Messageheader defined in Table 41. This allows the OPC UA Connection Protocol layer to extract the SecureChannel Messagesfrom the incoming stream even if it does not understand their contents.

The OPC UA Connection Protocol layer shall verify the MessageTypeand make sure the MessageSizeis less than the negotiated ReceiveBufferSizebefore passing any Messageonto the SecureChannellayer.

The Hello Messagehas the additional fields shown in Table 51.

Table 51– OPC UA Connection ProtocolHello Message

Name

Data Type

Description

ProtocolVersion

UInt32

The latest version of the UACP protocol supported by the Client.

The Servermay reject the Clientby returning Bad_ProtocolVersionUnsupported.

If the Serveraccepts the connection is responsible for ensuring that it returns Messagesthat conform to this version of the protocol.

The Servershall always accept versions greater than what it supports.

ReceiveBufferSize

UInt32

The largest MessageChunkthat the sender can receive.

SendBufferSize

UInt32

The largest MessageChunkthat the sender will send.

MaxMessageSize

UInt32

The maximum size for any response Message. The Servershall abort the Messagewith a Bad_ResponseTooLarge Error Messageif a response Messageexceeds this value.

The mechanism for aborting Messagesis described fully in 6.7.3.

The Messagesize is calculated using the unencrypted Messagebody.

A value of zero indicates that the Clienthas no limit.

MaxChunkCount

UInt32

The maximum number of chunks in any response Message.

The Servershall abort the Messagewith a Bad_ResponseTooLarge Error Messageif a response Messageexceeds this value.

The mechanism for aborting Messagesis described fully in 6.7.3.

A value of zero indicates that the Clienthas no limit.

EndpointUrl

String

The URL of the Endpointwhich the Clientwished to connect to.

The encoded value shall be less than 4 096 bytes.

Serversshall return a Bad_TcpEndpointUrlInvalid Error Messageand close the connection if the length exceeds 4 096 or if it does not recognize the resource identified by the URL.

The EndpointUrlparameter is used to allow multiple Serversto share the same endpoint on a machine. The process listening (also known as the proxy) on the endpoint would connect to the Serveridentified by the EndpointUrland would forward all Messagesto the Servervia this socket. If one socket closes, then the proxy shall close the other socket.

If the Serverdoes not have sufficient resources to allow the establishment of a new SecureChannelit shall immediately return a Bad_TcpNotEnoughResources Error Messageand gracefully close the socket. Clientshould not overload Serversthat return this error by immediately trying to create a new SecureChannel.

The Acknowledge Messagehas the additional fields shown in Table 52.

Table 52– OPC UA Connection Protocol Acknowledge Message

Name

Type

Description

ProtocolVersion

UInt32

The latest version of the UACP protocol supported by the Server.

If the Clientaccepts the connection is responsible for ensuring that it sends Messagesthat conform to this version of the protocol.

The Clientshall always accept versions greater than what it supports.

ReceiveBufferSize

UInt32

The largest MessageChunkthat the sender can receive.

This value shall not be larger than what the Clientrequested in the Hello Message.

SendBufferSize

UInt32

The largest MessageChunk that the sender will send.

This value shall not be larger than what the Clientrequested in the Hello Message.

MaxMessageSize

UInt32

The maximum size for any request Message. The Clientshall abort the Messagewith a Bad_RequestTooLarge StatusCodeif a request Messageexceeds this value.

The mechanism for aborting Messagesis described fully in 6.7.3.

The Messagesize is calculated using the unencrypted Messagebody.

A value of zero indicates that the Serverhas no limit.

MaxChunkCount

UInt32

The maximum number of chunks in any request Message.

The Clientshall abort the Messagewith a Bad_RequestTooLarge StatusCodeif a request Messageexceeds this value.

The mechanism for aborting Messagesis described fully in 6.7.3.

A value of zero indicates that the Serverhas no limit.

The Error Messagehas the additional fields shown in Table 53.

Table 53– OPC UA Connection Protocol Error Message

Name

Type

Description

Error

UInt32

The numeric code for the error.

This shall be one of the values listed in Table 55.

Reason

String

A more verbose description of the error.

This string shall not be more than 4 096 bytes.

A Clientshall ignore strings that are longer than this.

The socket is always closed gracefully by the Clientafter it receives an Error Message.

The ReverseHello Messagehas the additional fields shown in Table 54.

Table 54– OPC UA Connection Protocol ReverseHello Message

Name

Data Type

Description

ServerUri

String

The ApplicationUriof the Serverwhich sent the Message.

The encoded value shall be less than 4 096 bytes.

Clientshall return a Bad_TcpEndpointUrlInvalid error and close the connection if the length exceeds 4 096 or if it does not recognize the Serveridentified by the URI.

EndpointUrl

String

The URL of the Endpointwhich the Clientuses when establishing the SecureChannel.

This value shall be passed back to the Serverin the Hello Message.

The encoded value shall be less than 4 096 bytes.

Clientsshall return a Bad_TcpEndpointUrlInvalid error and close the connection if the length exceeds 4 096 or if it does not recognize the resource identified by the URL.

This value is a unique identifier for the Serverwhich the Clientmay use to look up configuration information. It should be one of the URLs returned by the GetEndpoints Service.

For connection based protocols, such as TCP, the ReverseHello Messageallows Serversbehind firewalls with no open ports to connect to a Clientand request that the Clientestablish a SecureChannelusing the socket created by the Server.

For message based protocols the ReverseHello Messageallows Serversto announce their presence to a Client. In this scenario, the EndpointUrlspecifies the Server’sprotocol specific address and any tokens required to access it.