BiancoRoyal / node-red-contrib-iiot-opcua

deprecated - very new developed by PLUS for Node-RED - https://plus4nodered.com
https://www.npmjs.com/package/node-red-contrib-iiot-opcua
BSD 3-Clause "New" or "Revised" License
34 stars 9 forks source link

OPC-UA connector not working anymore #11

Closed deminngi closed 6 years ago

deminngi commented 6 years ago

Hi Klaus,

tried 2.0.5 and 2.0.8 cannot connect to an OPC-UA server anymore. It works before, log shows [ 'opc.tcp://10.1.27.101:4840 NONE http://opcfoundation.org/UA/SecurityPolicy#None' ]

biancode commented 6 years ago

strange ... just with a clean install I had that problem in my development environment ... should be fixed with v2.0.9

deminngi commented 6 years ago

Tested and deployed 2.0.9 same error [ 'opc.tcp://10.1.27.101:4840 NONE http://opcfoundation.org/UA/SecurityPolicy#None' ]

The listener node cannot connect to an external OPC/UA server the status message is always waiting...

deminngi commented 6 years ago

I am not sure, I guess the problem is coming from node-opcua CreateSession ? node-opcua 0.2.2 [1369c25] OPCUAClient#connect now ensures that endpoint exists on server ( use ensure_endpoint_exists:false to revert to old behavior)

biancode commented 6 years ago

v2.0.9 is on node-opcua 0.2.1 and it works for me

image

biancode commented 6 years ago

You'll get the endpoint in debug log - try the given endpoint, please

biancode commented 6 years ago

Please test the v2.0.10, what you get for the endpoints

screen shot 2018-02-25 at 11 46 06
deminngi commented 6 years ago

Nothing changed since 2.0.5:

Keep in mind: The OPC-UA server has two adapter, I can connect on the external adapter, I guess the OPC-UA server is broadcasting the second internal adapter on a different network.

Let me test it tomorrow morning to figure out what is happening and what has changed from last week.

Questions: What caused this breaking change? Should I enable DEBUG on IIOTConnector to track down the problem?

biancode commented 6 years ago

Questions: What caused this breaking change? API changed in major style for node-opcua 0.2.x and I am working in iterative steps to fix all until 2.1.x You could also use v1.x of my package if 2.x is not stable for you

Should I enable DEBUG on IIOTConnector to track down the problem? Yes, but better to see is a DEBUG=opcuaIIoT* log

biancode commented 6 years ago

opc.tcp://pcname.mshome.net:53530/

biancode commented 6 years ago
screen shot 2018-02-26 at 00 14 59
biancode commented 6 years ago

image

biancode commented 6 years ago

I have tested with the opcua-commander and it looks like an issue in node-opcua. Please, open an issue for that at node-opcua!

biancode commented 6 years ago

tested with opcua-commander v0.2.1 and v0.2.2 node-opcua

deminngi commented 6 years ago

Hi @biancode

Here is the debug output from the connector using:

DEBUG=opcuaIIoT:client,opcuaIIoT:listener,opcuaIIoT:connector,

please bear in mind my OPC-UA server has two network adapter LAN and WAN. the 10.0.1.123 is my LAN address and 10.1.27.101 is my WAN address. I want to connect from the LAN side using 10.0.1.123

2018-02-27T03:47:50.767Z opcuaIIoT:connector:details config: 2018-02-27T03:47:50.769Z opcuaIIoT:connector:details default key: /data/red/node_modules/node-opcua-client/certificates/client_selfsigned_cert_1024.pem 2018-02-27T03:47:50.770Z opcuaIIoT:connector:details config: 2018-02-27T03:47:50.770Z opcuaIIoT:connector:details default key: /data/red/node_modules/node-opcua-client/certificates/PKI/own/private/private_key.pem 2018-02-27T03:47:52.784Z opcuaIIoT:connector Connecting On opc.tcp://10.0.1.123:4840 2018-02-27T03:47:52.785Z opcuaIIoT:connector:details Options {"securityPolicy":"None","securityMode":"NONE","defaultSecureTokenLifetime":"60000","keepSessionAlive":true,"certificateFile":"/data/red/node_modules/node-opcua-client/certificates/client_selfsigned_cert_1024.pem","privateKeyFile":"/data/red/node_modules/node-opcua-client/certificates/PKI/own/private/private_key.pem"} 2018-02-27T03:47:53.158Z opcuaIIoT:connector Connected On opc.tcp://10.0.1.123:4840 Options {"securityPolicy":"None","securityMode":"NONE","defaultSecureTokenLifetime":"60000","keepSessionAlive":true,"certificateFile":"/data/red/node_modules/node-opcua-client/certificates/client_selfsigned_cert_1024.pem","privateKeyFile":"/data/red/node_modules/node-opcua-client/certificates/PKI/own/private/private_key.pem"} 2018-02-27T03:47:53.179Z opcuaIIoT:connector endpoint: opc.tcp://10.1.27.101:4840 2018-02-27T03:47:53.179Z opcuaIIoT:connector urn:10.1.27.101 2018-02-27T03:47:53.180Z opcuaIIoT:connector:details NONE 2018-02-27T03:47:53.180Z opcuaIIoT:connector:details securityPolicyUri: http://opcfoundation.org/UA/SecurityPolicy#None 2018-02-27T03:47:53.183Z opcuaIIoT:connector:details endpoint: opc.tcp://10.1.27.101:4840 2018-02-27T03:47:53.183Z opcuaIIoT:connector:details Application URI: urn:10.1.27.101 2018-02-27T03:47:53.184Z opcuaIIoT:connector:details Product URI: urn:10.1.27.101 2018-02-27T03:47:53.184Z opcuaIIoT:connector:details Application Name: Loytec OPC UA Server 2018-02-27T03:47:53.184Z opcuaIIoT:connector:details Type: SERVER 2018-02-27T03:47:53.184Z opcuaIIoT:connector:details NONE 2018-02-27T03:47:53.185Z opcuaIIoT:connector:details securityPolicyUri: http://opcfoundation.org/UA/SecurityPolicy#None 2018-02-27T03:47:53.185Z opcuaIIoT:connector:details discoveryUrls: opc.tcp://10.1.27.101:4840 2018-02-27T03:47:53.185Z opcuaIIoT:connector:details serverCertificate: None 2018-02-27T03:47:53.186Z opcuaIIoT:connector:details Identify Token for : Security Mode=NONE Policy=http://opcfoundation.org/UA/SecurityPolicy#None 2018-02-27T03:47:53.188Z opcuaIIoT:connector:details policyId: NoIdentityTokens 2018-02-27T03:47:53.188Z opcuaIIoT:connector:details tokenType: ANONYMOUS 2018-02-27T03:47:53.188Z opcuaIIoT:connector:details issuedTokenType: null 2018-02-27T03:47:53.189Z opcuaIIoT:connector:details issuerEndpointUrl: null 2018-02-27T03:47:53.189Z opcuaIIoT:connector:details securityPolicyUri: null 2018-02-27T03:47:53.192Z opcuaIIoT:connector Setup Certified Options For opc.tcp://10.0.1.123:4840 2018-02-27T03:47:53.192Z opcuaIIoT:connector:details Options {"securityPolicy":"None","securityMode":"NONE","defaultSecureTokenLifetime":"60000","keepSessionAlive":true,"certificateFile":"/data/red/node_modules/node-opcua-client/certificates/client_selfsigned_cert_1024.pem","privateKeyFile":"/data/red/node_modules/node-opcua-client/certificates/PKI/own/private/private_key.pem"} 2018-02-27T03:47:53.216Z opcuaIIoT:connector !!!!!!!!!!!!!!!!!!!!!!!! CONNECTION CLOSED !!!!!!!!!!!!!!!!!!! 2018-02-27T03:47:53.226Z opcuaIIoT:connector Disconnected From opc.tcp://10.0.1.123:4840 2018-02-27T03:47:53.227Z opcuaIIoT:connector:details Options {"securityPolicy":"None","securityMode":"NONE","defaultSecureTokenLifetime":"60000","certificateFile":"/data/red/node_modules/node-opcua-client/certificates/client_selfsigned_cert_1024.pem","privateKeyFile":"/data/red/node_modules/node-opcua-client/certificates/PKI/own/private/private_key.pem"} 2018-02-27T03:47:53.295Z opcuaIIoT:connector Secured Connected On opc.tcp://10.0.1.123:4840 2018-02-27T03:47:53.295Z opcuaIIoT:connector:details Options {"securityPolicy":"None","securityMode":"NONE","defaultSecureTokenLifetime":"60000","certificateFile":"/data/red/node_modules/node-opcua-client/certificates/client_selfsigned_cert_1024.pem","privateKeyFile":"/data/red/node_modules/node-opcua-client/certificates/PKI/own/private/private_key.pem"} 2018-02-27T03:47:53.297Z opcuaIIoT:listener starting OPC UA session with delay of 1000 2018-02-27T03:47:54.299Z opcuaIIoT:listener Listener Start OPC UA Session 2018-02-27T03:47:54.302Z opcuaIIoT:connector Request For New Session From Listener Node [ 'opc.tcp://10.1.27.101:4840 NONE http://opcfoundation.org/UA/SecurityPolicy#None' ] 2018-02-27T03:47:54.354Z opcuaIIoT:connector Session Start Error Error: End point must exist opc.tcp://10.0.1.123:4840 2018-02-27T03:47:54.356Z opcuaIIoT:listener Handle Session Error Error: End point must exist opc.tcp://10.0.1.123:4840

biancode commented 6 years ago

@erossignon - please - some idea about that problem? - I tested with ProSys server too and it does not work - same problem with the opcua-commander

erossignon commented 6 years ago

@biancode , I suspect this is happening in a development situation , I came across similar issue that could be resolved by a clean install. Did you add the ensure_endpoint_exists: false in your OPCUAClient call ?

try the following:

erossignon commented 6 years ago

BTW, I just retested installing opcua-commander@0.2.2 this way and it worked as expected

npm install opcua-commander -g
opcua-commander opc.tcp://MYLAPTOP:53530/OPCUA/SimulationServer
biancode commented 6 years ago

OK, I'll add the endpoint_must_exist option to control from node settings.

biancode commented 6 years ago

@erossignon thank you - step forward but Internal Error in ProSys server.

image

screen shot 2018-02-28 at 21 10 49
biancode commented 6 years ago

image

biancode commented 6 years ago
screen shot 2018-02-28 at 21 13 54
demetz commented 6 years ago

Hi,

I have a similar / the same issue: I can't connect to an opc server using the current version.

node: v8.9.4 node-red: v0.17.5 node-opcua: v0.2.2 node-red-contrib-iiot-opcua: v2.0.12

opc ua server: open62541

I can connect without problems using UAExpert. Using node-red / OPCUA-IIoT, I get the following errors on the server:

[03/05/2018 19:56:23.715] info/network Connection 5 | New connection over TCP from 192.168.178.36:40705 [03/05/2018 19:56:23.814] info/channel Connection 5 | SecureChannel 2 | OpenSecureChannel: Opened SecureChannel [03/05/2018 19:56:23.828] info/session Try to use Session with token 00000000-0000-0000-0000-000000000000 but is not found [03/05/2018 19:56:25.919] info/session Try to use Session with token 00000000-0000-0000-0000-000000000000 but is not found [03/05/2018 19:56:25.927] info/channel Connection 5 | SecureChannel 2 | CloseSecureChannel [03/05/2018 19:57:25.948] info/network Connection 6 | New connection over TCP from 192.168.178.36:40791 [03/05/2018 19:57:25.967] info/channel Connection 6 | SecureChannel 3 | OpenSecureChannel: Opened SecureChannel [03/05/2018 19:57:25.984] info/session Try to use Session with token 00000000-0000-0000-0000-000000000000 but is not found [03/05/2018 19:57:27.036] info/session Connection 0 | SecureChannel 0 | Session dd73bc5f-2f84-a3ea-e0ce-5ca505509509 | ActivateSession: SecureChannel 3 wants to activate, but the UserIdentify token is invalid

In node-red, I receive:

"Error: ServiceResult is BadIdentityTokenInvalid (0x80200000)"

biancode commented 6 years ago

older issues on node-opcua for that