ClientSecureChannelLayer Class
a ClientSecureChannelLayer represents the client side of the OPCUA secure channel.
Constructor
ClientSecureChannelLayer
-
options
Parameters:
-
options
Object-
[defaultSecureTokenLifetime=30000 ]
Number optional -
[tokenRenewalInterval=0]
Number optionalif 0, security token renewa&l will happen at 75% of defaultSecureTokenLifetime
-
[securityMode=MessageSecurityMode.NONE]
optional -
[securityPolicy=SecurityPolicy.None]
optional -
[serverCertificate=null]
optionalthe serverCertificate (required if securityMode!=None)
-
parent
OPCUAClientBaseparent
-
[factory]
optionalan factory that provides a method createObjectId(id) for the message builder
-
[transportTimeout= ClientSecureChannelLayer.defaultTransportTimeout ]
optionalthe transport timeout interval in ms
-
[connectionStrategy]
Object optional-
[maxRetry= 10]
optional -
[initialDelay= 10]
optional -
[maxDelay= 10000]
optional
-
-
Item Index
Methods
Properties
Methods
_performMessageTransaction
-
msgType
-
requestMessage
-
callback
internal version of _performMessageTransaction.
Parameters:
-
msgType
String -
requestMessage
Object -
callback
Object
_read_headers
-
binaryStream
Parameters:
-
binaryStream
Object
Returns:
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
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
establish a secure channel with the provided server end point.
Parameters:
-
endpointUrl
String -
callback
Functionthe 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");
}
});
getAllEventType
getAllEventType recursively
-
session
-
callback
Parameters:
-
session
Object -
callback
Object
getPrivateKey
()
Buffer
Returns:
the privateKey
makeRequestId
()
Number
private
Returns:
a newly generated request id
performMessageTransaction
-
requestMessage
-
callback
perform a OPC-UA message transaction, asynchronously.
Parameters:
-
requestMessage
Object -
callback
FunctionDuring 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
Parameters:
-
str
Object
Returns:
Example:
toDate("now"); toDate("13:00"); => today at 13:00 toDate("1 hour ago"); => today one our ago....
update
-
options
Parameters:
-
options
Object-
securityHeader
ObjectSecurityHeader
-
[derivedKeys]
Object optionalderivedKeys
-
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
backoff
backoff
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
Event Payload:
-
expected
Numbersequence Number -
actual
Numbersequence 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
Event Payload:
-
objMessage
Objectthe decoded message object -
msgType
Stringthe message type ( "HEL","ACK","OPN","CLO" or "MSG" ) -
the
Numberrequest 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
Objectthe 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
Objectthe 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
Objectthe message chunk