ClientSecureChannelLayer Class
a ClientSecureChannelLayer represents the client side of the OPCUA secure channel.
Constructor
ClientSecureChannelLayer
        
                - 
                                
options 
Parameters:
- 
                                
optionsObject- 
                                            
[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)
 - 
                                            
parentOPCUAClientBaseparent
 - 
                                            
[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:
- 
                                            
msgTypeString - 
                                            
requestMessageObject - 
                                            
callbackObject 
_read_headers
                    
                            - 
                                            
binaryStream 
Parameters:
- 
                                            
binaryStreamObject 
Returns:
chunkSecureMessage
                    
                            - 
                                            
msgType - 
                                            
options - 
                                            
message - 
                                            
messageChunkCallback 
Parameters:
- 
                                            
msgTypeString - 
                                            
optionsObject- 
                                                        
tokenId - 
                                                        
chunkSize[default=8196]
 - 
                                                        
signatureLengthInteger[default=0]
 - 
                                                        
signingFuncFunction[default=null]
 
 - 
                                                        
 - 
                                            
messageObject - 
                                            
messageChunkCallbackFunction 
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:
- 
                                            
callbackFunction 
create
                    
                            - 
                                            
endpointUrl - 
                                            
callback 
establish a secure channel with the provided server end point.
Parameters:
- 
                                            
endpointUrlString - 
                                            
callbackFunctionthe async callback function
- 
                                                        
errError | 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:
- 
                                            
sessionObject - 
                                            
callbackObject 
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:
- 
                                            
requestMessageObject - 
                                            
callbackFunctionDuring 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:
- 
                                            
strObject 
Returns:
Example:
toDate("now"); toDate("13:00"); => today at 13:00 toDate("1 hour ago"); => today one our ago....
update
                    
                            - 
                                            
options 
Parameters:
- 
                                            
optionsObject- 
                                                        
securityHeaderObjectSecurityHeader
 - 
                                                        
[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:
- 
                                            
errorError 
invalid_sequence_number
                        
                    
                    
                    
                    
                    
                        
                    
                        Event Payload:
- 
                                            
expectedNumbersequence Number - 
                                            
actualNumbersequence 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:
- 
                                            
securityTokenObject: the security token that is about to expire.
 
message
                        
                    
                    
                    
                    
                    
                        
                    
                        Event Payload:
- 
                                            
objMessageObjectthe decoded message object - 
                                            
msgTypeStringthe message type ( "HEL","ACK","OPN","CLO" or "MSG" ) - 
                                            
theNumberrequest Id 
receive_chunk
                        
                    
                    
                    
                    
                    
                        
                    
                        notify the observers that ClientSecureChannelLayer has received a message chunk
Event Payload:
- 
                                            
message_chunkBuffer 
receive_response
                        
                    
                    
                    
                    
                    
                        
                    
                        notify the observers that a server response has been received on the channel
Event Payload:
- 
                                            
responseObjectthe 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_chunkObjectthe message chunk
 
send_request
                        
                    
                    
                    
                    
                    
                        
                    
                        notify the observer that a client request is being sent the server
Event Payload:
- 
                                            
requestMessageObject 
timed_out_request
                        
                    
                    
                    
                    
                    
                        
                    
                        notify the observer that the response from the request has not been received within the timeoutHint specified
Event Payload:
- 
                                            
message_chunkObjectthe message chunk
 
            The NodeOPCUA API