APIs

Show:

a ClientSecureChannelLayer represents the client side of the OPCUA secure channel.

Constructor

ClientSecureChannelLayer

(
  • options
)

Parameters:

  • options Object
    • [defaultSecureTokenLifetime=30000 ] Number optional
    • [tokenRenewalInterval=0] Number optional

      if 0, security token renewa&l will happen at 75% of defaultSecureTokenLifetime

    • [securityMode=MessageSecurityMode.NONE] optional
    • [securityPolicy=SecurityPolicy.None] optional
    • [serverCertificate=null] optional

      the serverCertificate (required if securityMode!=None)

    • parent OPCUAClientBase

      parent

    • [factory] optional

      an factory that provides a method createObjectId(id) for the message builder

    • [transportTimeout= ClientSecureChannelLayer.defaultTransportTimeout ] optional

      the transport timeout interval in ms

    • [connectionStrategy] Object optional
      • [maxRetry= 10] optional
      • [initialDelay= 10] optional
      • [maxDelay= 10000] optional

Methods

_performMessageTransaction

(
  • msgType
  • requestMessage
  • callback
)
private

internal version of _performMessageTransaction.

Parameters:

  • msgType String
  • requestMessage Object
  • callback Object

_read_headers

(
  • binaryStream
)
Boolean private

Parameters:

  • binaryStream Object

Returns:

Boolean:

chunkSecureMessage

(
  • msgType
  • options
  • message
  • messageChunkCallback
)

Parameters:

  • msgType String
  • options Object
    • tokenId
    • chunkSize

      [default=8192]

    • signatureLength Number

      [default=0]

    • signingFunc Function

      [default=null]

  • message Object
  • messageChunkCallback Function

close

(
  • callback
)
async

Close a client SecureChannel ,by sending a CloseSecureChannelRequest to the server.

After this call, the connection is closed and no further transaction can be made.

Parameters:

  • callback Function

create

(
  • endpointUrl
  • callback
)
async

establish a secure channel with the provided server end point.

Parameters:

  • endpointUrl String
  • callback Function

    the async callback function

    • err Error | Null

Example:


                    var secureChannel  = new ClientSecureChannelLayer();
                    
                    secureChannel.on("end", function(err) {
                         console.log("secure channel has ended",err);
                         if(err) {
                            console.log(" the connection was closed by an external cause such as server shutdown");
                        }
                    });
                    secureChannel.create("opc.tcp://localhost:1234/UA/Sample", function(err) {
                         if(err) {
                              console.log(" cannot establish secure channel" , err);
                         } else {
                              console.log("secure channel has been established");
                         }
                    });
                    
                    

get

() Variant

returns the current value as a Variant

Returns:

getAllEventType getAllEventType recursively

(
  • session
  • callback
)

Parameters:

  • session Object
  • callback Object

getPrivateKey

() Buffer

Returns:

Buffer:

the privateKey

makeRequestId

() Number private

Returns:

Number:

a newly generated request id

performMessageTransaction

(
  • requestMessage
  • callback
)

perform a OPC-UA message transaction, asynchronously.

Parameters:

  • requestMessage Object
  • callback Function

    During a transaction, the client sends a request to the server. The provided callback will be invoked at a later stage with the reply from the server, or the error.

    preconditions:

    • the channel must be opened

Example:

var secure_channel ; // get a  ClientSecureChannelLayer somehow
                    
                    var message = new BrowseRequest({...});
                    secure_channel.performMessageTransaction(message,function(err,response) {
                       if (err) {
                         // an error has occurred
                       } else {
                          assert(response instanceof BrowseResponse);
                         // do something with response.
                       }
                    });
                    

toDate

(
  • str
)
Date

Parameters:

  • str Object

Returns:

Date:

Example:

toDate("now"); toDate("13:00"); => today at 13:00 toDate("1 hour ago"); => today one our ago....

update

(
  • options
)

Parameters:

  • options Object
    • securityHeader Object

      SecurityHeader

    • [derivedKeys] Object optional

      derivedKeys

Properties

isConnecting

Boolean

true if the secure channel is trying to establish the connection with the server. In this case, the client may be in the middle of the b ackoff connection process.

Events

close

notify the observers that the transport connection has ended. The error object is null or undefined if the disconnection was initiated by the ClientSecureChannelLayer. A Error object is provided if the disconnection has been initiated by an external cause.

Event Payload:

  • error Error

invalid_sequence_number

notify the observers that a message with an invalid sequence number has been received.

Event Payload:

  • expected Number
    sequence Number
  • actual Number
    sequence Number

lifetime_75

notify the observer that the secure channel has now reach 75% of its allowed live time and that a new token is going to be requested.

Event Payload:

  • securityToken Object

    : the security token that is about to expire.

message

notify the observers that a full message has been received

Event Payload:

  • objMessage Object
    the decoded message object
  • msgType String
    the message type ( "HEL","ACK","OPN","CLO" or "MSG" )
  • the Number
    request Id

receive_chunk

notify the observers that ClientSecureChannelLayer has received a message chunk

Event Payload:

  • message_chunk Buffer

receive_response

notify the observers that a server response has been received on the channel

Event Payload:

  • response Object

    the response object

security_token_renewed

notify the observers that the security has been renewed

send_chunk

notify the observer that a message chunk is about to be sent to the server

Event Payload:

  • message_chunk Object

    the message chunk

send_request

notify the observer that a client request is being sent the server

Event Payload:

  • requestMessage Object

timed_out_request

notify the observer that the response from the request has not been received within the timeoutHint specified

Event Payload:

  • message_chunk Object

    the message chunk