Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no connection to Beckhoff PLC Simulation #25

Closed
dev4iotatgps opened this issue Jun 14, 2023 · 11 comments
Closed

no connection to Beckhoff PLC Simulation #25

dev4iotatgps opened this issue Jun 14, 2023 · 11 comments

Comments

@dev4iotatgps
Copy link

Hi,

I have following problem with the ads-client in node-red (v3.0.2). I use an Advantech IoT Router ICR3231W with Node-Red installed. I have also installed the node-red-contrib-ads and the node-red-contrib-ads-client. My Beckhoff TwinCAT 3.1.0.0 (EventLoggerVersion: 4024.47) is installed on a Windows 10x64 Lenovo Notebook. Router and Notebook is connected via a Netgear unmanaged switch. Firewall is disabled on both sides. At the TwinCAT ADS Router I have configured a route to my Node-Red

With the node-red-contrib-ads lib it was possible to get a connection to the PLC via the ADS System node. I was also able to read global variables from the PLC Simulation. I have configured the node as followed:
image

With the node-red-contrib-ads-client I am not able to get a connection to the PLC SIM. I use the ADS - Connection Status node.

image

image

Why is it working with the node-red-contrib-ads but not with the node-red-contrib-ads-client. When I started testing with the node-red-contrib-ads-client I have restarted the PLC Sim, restarted the Router where Node-Red is running on and deleted the configuration from the node-red-contrib-ads in Node-Red.

Thank you in advance!
Kind Regards,
Patrick

@jisotalo
Copy link
Owner

jisotalo commented Jun 14, 2023

Are you sure that you only have one connection at time? Only one connection is supported if no TwinCAT router installed (so make sure the other ads library is not running at the same time and connecting to this target).

Can you set debugging level to 3 and post the console output?

@dev4iotatgps
Copy link
Author

The other ads lib is not running and I have also removed the node configuration from the ads lib. After that, I have restarted the TwinCAT-System and the Router.

Here is the console output:

2023-06-15 11:05:30 [info] Starting flows 2023-06-15 11:05:30 [debug] red/nodes/flows.start : starting flow : global 2023-06-15 11:05:30 [debug] red/nodes/flows.start : starting flow : adbad0c8def14ca1 2023-06-15 11:05:30 [debug] red/nodes/flows.start : starting flow : 094d73ef8fd841d7 2023-06-15 11:05:30 [info] [ads-client-connection:79fed921af51fcd5] Connecting to 192.168.2.3.1.1:851... 2023-06-15 11:05:30 [info] Started flows 2023-06-15 11:05:32 [info] [ads-client-connection:79fed921af51fcd5] Connecting to 192.168.2.3.1.1:851 failed, keeping trying.. 2023-06-15 11:05:32 [warn] [ads-client-connection:79fed921af51fcd5] Failed to connect 192.168.2.3.1.1:851 at startup: ClientException: Connection to 192.168.2.3:48898 failed (timeout) - No response from router in 2000 ms 2023-06-15 11:06:18 [debug] saved flow revision: b097da4b6e7074bc3a53b4bb02238bf2 2023-06-15 11:06:18 [info] Stopping flows 2023-06-15 11:06:18 [debug] red/nodes/flows.stop : stopping flow : adbad0c8def14ca1 2023-06-15 11:06:18 [debug] red/nodes/flows.stop : stopping flow : 094d73ef8fd841d7 2023-06-15 11:06:18 [debug] red/nodes/flows.stop : stopping flow : global 2023-06-15 11:06:18 [info] [ads-client-connection:79fed921af51fcd5] Disconnecting from 192.168.2.3.1.1:851 and unsubscribing from all... 2023-06-15 11:06:18 [info] [ads-client-connection:79fed921af51fcd5] Disconnected from 192.168.2.3.1.1:851 2023-06-15 11:06:18 [info] Stopped flows 2023-06-15 11:06:18 [info] Updated flows 2023-06-15 11:06:18 [info] Starting flows 2023-06-15 11:06:18 [debug] red/nodes/flows.start : starting flow : global 2023-06-15 11:06:18 [debug] red/nodes/flows.start : starting flow : adbad0c8def14ca1 2023-06-15 11:06:18 [debug] red/nodes/flows.start : starting flow : 094d73ef8fd841d7 2023-06-15 11:06:18 [info] [ads-client-connection:79fed921af51fcd5] Connecting to 192.168.2.3.1.1:851... 2023-06-15 11:06:18 [info] Started flows 2023-06-15 11:06:20 [info] [ads-client-connection:79fed921af51fcd5] Connecting to 192.168.2.3.1.1:851 failed, keeping trying.. 2023-06-15 11:06:20 [warn] [ads-client-connection:79fed921af51fcd5] Failed to connect 192.168.2.3.1.1:851 at startup: ClientException: Connection to 192.168.2.3:48898 failed (timeout) - No response from router in 2000 ms 2023-06-15 11:06:20 [info] [debug:debug 5] { payload: false, connection: { connected: false, isLocal: false, localAmsNetId: null, localAdsPort: null, targetAmsNetId: '192.168.2.3.1.1', targetAdsPort: '851' }, _msgid: '7fdfebbe8159c317' }

@jisotalo
Copy link
Owner

jisotalo commented Jun 16, 2023 via email

@dev4iotatgps
Copy link
Author

16 Jun 11:25:18 - [info] Started flows

  ads-client _connect(): Socket connection established to 192.168.2.3:48898 +2ms

  ads-client:details _registerAdsPort(): Registering an ADS port from ADS router 192.168.2.3:48898 +513ms

  ads-client:details IO out ------> 8 bytes +0ms

  ads-client _connect(): Socket connection ended by remote, connection failed. +2ms

16 Jun 11:25:18 - [info] [ads-client-connection:dd14ce822fbd2590] Connecting to 192.168.2.3.1.1:851 failed, keeping trying..

16 Jun 11:25:18 - [warn] [ads-client-connection:dd14ce822fbd2590] Failed to connect 192.168.2.3.1.1:851 at startup: ClientException: Connection to 192.168.2.3:48898 failed - socket ended by remote

  ads-client _registerAdsPort(): Failed to register ADS port - Timeout - no response in 2000 ms +2s

  ads-client _disconnect(): Starting to close connection (force: false) +3ms

  ads-client _unsubscribeAllInternals(): Unsubscribing from all notifications +1ms

  ads-client _unsubscribeAllInternals(): Unsubscribed from 0 notifications +0ms

  ads-client:details _unregisterAdsPort(): Unregister ads port null from 192.168.2.3:48898 +2s

  ads-client:details IO out ------> 8 bytes +0ms

  ads-client _registerAdsPort(): Failed to unregister ADS port - Timeout - no response in 2000 ms +2s

  ads-client _disconnect(): Connection closed successfully +1ms

  ads-client setDebugging(): Debug level set to 3 +0ms

  ads-client _connect(): Starting to connect 192.168.2.3:48898 +0ms

  ads-client _connect(): Socket connection established to 192.168.2.3:48898 +1ms

  ads-client:details _registerAdsPort(): Registering an ADS port from ADS router 192.168.2.3:48898 +2s

  ads-client:details IO out ------> 8 bytes +0ms

  ads-client _connect(): Socket connect failed: Error: read ECONNRESET

  ads-client     at TCP.onStreamRead (node:internal/stream_base_commons:217:20) {

  ads-client   errno: -104,

  ads-client   code: 'ECONNRESET',

  ads-client   syscall: 'read'

  ads-client } +1s

  ads-client:details _registerAdsPort(): Socket connection errored. +1s

  ads-client _disconnect(): Starting to close connection (force: false) +2s

  ads-client _unsubscribeAllInternals(): Unsubscribing from all notifications +1ms

  ads-client _unsubscribeAllInternals(): Unsubscribed from 0 notifications +0ms

  ads-client:details _unregisterAdsPort(): Unregister ads port null from 192.168.2.3:48898 +2s

  ads-client:details IO out ------> 8 bytes +0ms

  ads-client _registerAdsPort(): Failed to unregister ADS port - Timeout - no response in 2000 ms +2s

  ads-client _disconnect(): Connection closed successfully +1ms

  ads-client setDebugging(): Debug level set to 3 +0ms

  ads-client _connect(): Starting to connect 192.168.2.3:48898 +0ms

  ads-client _connect(): Socket connection established to 192.168.2.3:48898 +4ms

  ads-client:details _registerAdsPort(): Registering an ADS port from ADS router 192.168.2.3:48898 +2s

  ads-client:details IO out ------> 8 bytes +0ms

@jisotalo
Copy link
Owner

Thanks. Please try to set manual ADS port. Se set the localAdsPort to something like 31859 or so.

@dev4iotatgps
Copy link
Author

With the localAdsPort it is not working:

21 Jun 11:52:38 - [warn] Encrypted credentials not found 21 Jun 11:52:38 - [info] Server now running at http://127.0.0.1:1880/ 21 Jun 11:52:38 - [info] Starting flows 21 Jun 11:52:38 - [info] Started flows 21 Jun 11:54:36 - [info] Stopping flows 21 Jun 11:54:36 - [info] Stopped flows 21 Jun 11:54:36 - [info] Updated flows 21 Jun 11:54:36 - [info] Starting flows 21 Jun 11:54:36 - [info] [ads-client-connection:22ead47109caa45b] Connecting to 192.168.2.3.1.1:851... ads-client _connect(): Starting to connect 192.168.2.3:48898 +0ms 21 Jun 11:54:36 - [info] Started flows ads-client _connect(): Socket connection established to 192.168.2.3:48898 +10ms ads-client:details _registerAdsPort(): Registering an ADS port from ADS router 192.168.2.3:48898 +0ms ads-client:details IO out ------> 8 bytes +0ms ads-client _connect(): Socket connection ended by remote, connection failed. +3ms 21 Jun 11:54:36 - [info] [ads-client-connection:22ead47109caa45b] Connecting to 192.168.2.3.1.1:851 failed, keeping trying.. 21 Jun 11:54:36 - [warn] [ads-client-connection:22ead47109caa45b] Failed to connect 192.168.2.3.1.1:851 at startup: ClientException: Connection to 192.168.2.3:48898 failed - socket ended by remote ads-client _registerAdsPort(): Failed to register ADS port - Timeout - no response in 2000 ms +2s ads-client _disconnect(): Starting to close connection (force: false) +4ms ads-client _unsubscribeAllInternals(): Unsubscribing from all notifications +1ms ads-client _unsubscribeAllInternals(): Unsubscribed from 0 notifications +1ms ads-client:details _unregisterAdsPort(): Unregister ads port null from 192.168.2.3:48898 +2s ads-client:details IO out ------> 8 bytes +1ms ads-client _registerAdsPort(): Failed to unregister ADS port - Timeout - no response in 2000 ms +2s ads-client _disconnect(): Connection closed successfully +1ms ads-client setDebugging(): Debug level set to 3 +1ms ads-client _connect(): Starting to connect 192.168.2.3:48898 +0ms ads-client _connect(): Socket connection established to 192.168.2.3:48898 +2ms ads-client:details _registerAdsPort(): Registering an ADS port from ADS router 192.168.2.3:48898 +2s ads-client:details IO out ------> 8 bytes +1ms ads-client _connect(): Socket connection ended by remote, connection failed. +3ms ads-client _registerAdsPort(): Failed to register ADS port - Timeout - no response in 2000 ms +2s ads-client _disconnect(): Starting to close connection (force: false) +4ms ads-client _unsubscribeAllInternals(): Unsubscribing from all notifications +0ms ads-client _unsubscribeAllInternals(): Unsubscribed from 0 notifications +0ms ads-client:details _unregisterAdsPort(): Unregister ads port null from 192.168.2.3:48898 +2s ads-client:details IO out ------> 8 bytes +0ms

@dev4iotatgps
Copy link
Author

Here is the tcpdump of the connection:

`root@Ubuntu22:~# tcpdump

tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on enp0s3, link-type EN10MB (Ethernet), snapshot length 262144 bytes
11:58:05.293321 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [S], seq 3118779934, win 64240, options [mss 1460,sackOK,TS val 3759176209 ecr 0,nop,wscale 7], length 0
11:58:05.294146 IP 192.168.2.3.48898 > Ubuntu22.31859: Flags [S.], seq 2203309405, ack 3118779935, win 65535, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0
11:58:05.294176 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [.], ack 1, win 502, length 0
11:58:05.294512 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [P.], seq 1:9, ack 1, win 502, length 8
11:58:05.295641 IP 192.168.2.3.48898 > Ubuntu22.31859: Flags [F.], seq 1, ack 9, win 8212, length 0
11:58:05.296523 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [.], ack 2, win 502, length 0
11:58:05.297055 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [F.], seq 9, ack 2, win 502, length 0
11:58:05.297524 IP 192.168.2.3.48898 > Ubuntu22.31859: Flags [.], ack 10, win 8212, length 0
11:58:09.302814 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [S], seq 3181427978, win 64240, options [mss 1460,sackOK,TS val 3759180219 ecr 0,nop,wscale 7], length 0
11:58:09.304043 IP 192.168.2.3.48898 > Ubuntu22.31859: Flags [S.], seq 2203437407, ack 3181427979, win 65535, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0
11:58:09.304131 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [.], ack 1, win 502, length 0
11:58:09.305986 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [P.], seq 1:9, ack 1, win 502, length 8
11:58:09.307391 IP 192.168.2.3.48898 > Ubuntu22.31859: Flags [F.], seq 1, ack 9, win 1026, length 0
11:58:09.308679 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [F.], seq 9, ack 2, win 502, length 0
11:58:09.309347 IP 192.168.2.3.48898 > Ubuntu22.31859: Flags [.], ack 10, win 1026, length 0
11:58:13.315650 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [S], seq 3244128443, win 64240, options [mss 1460,sackOK,TS val 3759184231 ecr 0,nop,wscale 7], length 0
11:58:13.317088 IP 192.168.2.3.48898 > Ubuntu22.31859: Flags [S.], seq 2203565409, ack 3244128444, win 65535, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0
11:58:13.317154 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [.], ack 1, win 502, length 0
11:58:13.318684 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [P.], seq 1:9, ack 1, win 502, length 8
11:58:13.320162 IP 192.168.2.3.48898 > Ubuntu22.31859: Flags [F.], seq 1, ack 9, win 1026, length 0
11:58:13.320718 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [.], ack 2, win 502, length 0
11:58:13.321858 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [F.], seq 9, ack 2, win 502, length 0
11:58:13.323024 IP 192.168.2.3.48898 > Ubuntu22.31859: Flags [.], ack 10, win 1026, length 0
11:58:17.328687 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [S], seq 3306832234, win 64240, options [mss 1460,sackOK,TS val 3759188244 ecr 0,nop,wscale 7], length 0
11:58:17.329480 IP 192.168.2.3.48898 > Ubuntu22.31859: Flags [S.], seq 2203693411, ack 3306832235, win 65535, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0
11:58:17.329545 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [.], ack 1, win 502, length 0
11:58:17.331275 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [P.], seq 1:9, ack 1, win 502, length 8
11:58:17.332440 IP 192.168.2.3.48898 > Ubuntu22.31859: Flags [F.], seq 1, ack 9, win 1026, length 0
11:58:17.334179 IP Ubuntu22.31859 > 192.168.2.3.48898: Flags [F.], seq 9, ack 2, win 502, length 0
11:58:17.335374 IP 192.168.2.3.48898 > Ubuntu22.31859: Flags [.], ack 10, win 1026, length 0

`

@jisotalo
Copy link
Owner

jisotalo commented Jun 21, 2023

Hi!

Are you absolute sure that the localAmsNetId and localAdsPort settings are saved?

Because from debug logs it seems that it's still trying to register a port from target.

There is _registerAdsPort(): Registering an ADS port from ADS router 192.168.2.3:48898 in the log but it's not followed by _registerAdsPort(): Local AmsNetId and ADS port manually given so using xxx (see https://github.com/jisotalo/ads-client/blob/d5a0fe33359974d3aee1d5634093d6a86d2de693/src/ads-client.js#L3692)

If they are saved and should be OK, then there might be a bug in this Node-RED library and the settings are not used.

@dev4iotatgps
Copy link
Author

ok, now it is working! I have put the port wich you have mentioned above into the wrong field.. (localTcpPort)
Sorry! Thank you for your help!

What I do not understand is, when I leave the localAdsPort empty, there is also no localAmsNetId in the connection object, but I have set up a localAmsNetId

image

@dev4iotatgps
Copy link
Author

This is the working config:

image

@jisotalo
Copy link
Owner

Glad to hear it's working! The reason you need to give these manually is that you don't have a AMS router running on your device.

The connection object should contain localAmsNetId and localAdsPort but in your picture it's not connected. They are set after successful connection if I remember right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants