roccomuso / node-ads

NodeJS Twincat ADS protocol implementation
58 stars 21 forks source link

I use a CX5020 for my trials and also have problems to connect #24

Closed PLCHome closed 5 years ago

PLCHome commented 5 years ago

Hello @roccomuso , I use a CX5020 for my trials and also have problems to connect. I tried a several times different combinations of Adresses NetIds and ports but no success. Here are the error messages I face: "Error ADS: Error: connect ECONNREFUSED 192.168.137.235:48898" "Error readDeviceInfo: timeout" "Ads Register Notification live tick timeout" "Ads Register Notification Sym Tab timeout"

the ECONNREFUSED message sometimes dissappears suddenly but also suddenly comes back without having made any config changes.

Originally posted by @Wolfskammer04 in https://github.com/roccomuso/node-ads/issues/1#issuecomment-424350988

PLCHome commented 5 years ago

@Wolfskammer04 Configuration

Enable ADS on your PLC project. To do this click on your task and then enable the checkbox before Create symbols (if he is not disabled). In addition, you can still, under I/O Devices

Attention

Setting Up an ADS Remote Connection

Wolfskammer04 commented 5 years ago

Hi ChrisHanuta, I did all the steps a several time, no success. Today I also tried to use node-ads only - in principe the same results. I planned to get in touch with Beckhoff, to find another tool to check if ADS is working properly.

PLCHome commented 5 years ago

I have a cx5020 and a cx1020 with tc2 it runs fine.

Do you work under windows or Linux with node? Are you working on a seperate system? Witch TC version on 3 the port is 851? Is the PC clear, no twincat running? Is the system manager on the PC down (this)? There are also problems running node on the PLC #8 . Is the PLC in RUN or config mode?

Wolfskammer04 commented 5 years ago

node runs on an embedded linux system in a NodeRED - container of the HARTING MICA (https://www.harting-mica.com/en). I can ping the PLC from there. BUT I also get these timeout errors using a nodejs with 'node-ads' under the connected Win7 PC, where VS2012 is running at.

I program it with TC3 under VS2012, Win7

I used the port 851,

Is the PC clear, no twincat running? - I don't understand, what means no TC running under TC3?

At least all 2 'Create Symblos' checkboxes are checked.

PLC is in RUN mode.

PLCHome commented 5 years ago

node runs on an embedded linux system in a NodeRED - container

There is also a node for NODE-RED: node-red-contrib-ads It uses a foke of this implementation

Is the PC clear, no twincat running?

The Twincat router in some Twincat versions breaks the connection when the System Manager is running on the system

Wolfskammer04 commented 5 years ago

Hi, I installed a brand new node-red-contrib-ads: I now get the following messages:

{ connectState: 2, connectStateText: "CONNECTED", adsState: 0, adsStateText: "INVALID" } 28.9.2018, 09:19:37node: e3105093.b7101msg : string[43] "Ads Register Notification live tick timeout" 28.9.2018, 09:19:37node: e3105093.b7101msg : string[41] "Ads Register Notification Sym Tab timeout" 28.9.2018, 09:19:37node: e3105093.b7101msg : string[29] "Error readDeviceInfo: timeout" 28.9.2018, 09:19:38node: e3105093.b7101msg : string[43] "Ads Register Notification live tick timeout" 28.9.2018, 09:19:39node: e3105093.b7101msg : string[41] "Ads Register Notification Sym Tab timeout" 28.9.2018, 09:19:40node: e3105093.b7101msg : string[29] "Error readDeviceInfo: timeout" 28.9.2018, 09:19:40node: 486c33cd.975f34 msg.payload : Object { connectState: 0, connectStateText: "DISCONNECTED", adsState: 0, adsStateText: "INVALID" }

so it seems to connect to the CX5020 but while connected I get a couple of timeout messages and what means adsStateText: "INVALID"?

m8335la commented 5 years ago

Hi everyone,

read through your comments and I am facing a similar problem. My setup is a Beckhoff CX9020 running TwinCat 2 and I'm connecting from a Synology DS 215j hosted chroot environment in production and from a MacOS environment in development.

My setup worked fine using the old library (https://www.npmjs.com/package/ads). Then, for multi-read capabilities, I tried to upgrade to the new packages (https://www.npmjs.com/package/node-ads, https://www.npmjs.com/package/node-ads-api). Having nothing changed on the PLC side, I still was able to connect but also received the connection timeout.

I then went ahead and increased the timeout in node_modules/node-ads-api/lib in line 968:

` this.pending[this.invokeId] = {cb: options.cb, timeout: setTimeout(function () { delete this.pending[this.invokeId]

  options.cb('timeout')
}.bind(this), 5000)}`

Right then, the setup worked again :-)

PLCHome commented 5 years ago

Please set the timeout over the options var ads = require('node-ads')

var options = { host: "10.0.0.2", amsNetIdTarget: "5.1.204.160.1.1", amsNetIdSource: "192.168.137.50.1.1", timeout: 100000 }

var client = ads.connect(options, function() { this.readDeviceInfo(function(err, result) { if (err) console.log(err) console.log(result) this.end() }) })

client.on('error', function(error) { console.log(error) })