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

Socket closes after 10 seconds - Error: This socket has been ended by the other party #30

Open
JonFranklin301 opened this issue Dec 16, 2019 · 2 comments

Comments

@JonFranklin301
Copy link

Hi there,

I am using the notify method this to read position feedback from axes, however i am finding that the socket connection closes after approx 10 seconds.

 const options = {
    host: '10.4.4.1',
    amsNetIdTarget: '10.4.4.1.1.1',
    amsNetIdSource: '10.4.4.2.1.1',
  };

// Reading this...
  var myHandle = {
    symname: 'GVL.fbRevolve.rPosition',
    bytelength: ads.LREAL,
  };

    var client = ads.connect(options, function() {
      this.notify(myHandle);
    });

  client.on('notification', function(handle) {
    console.log(handle.value);
  });

  client.on('close', function(data) {
    console.log('CLOSE', data);
  });

 client.on('error', function(err) {
    console.log('Error: ', err);
  });

This works correctly for about 10 seconds before the socket is closed.

I thought it may have been a timeout somewhere, maybe the client not sending data frequently enough(?), so have added the following:

var client = ads.connect(options, function() {
      this.notify(myHandle);

setInterval(() => {
        this.readDeviceInfo(function(err, result) {
          if (err) console.log('Error: ', err);
          console.log('\nreadDeviceInfo: ', result);
          // this.end();
        });
      }, 1000);
    });

however after about 10 seconds the following gets thrown:

Error: Error: This socket has been ended by the other party
at Socket.writeAfterFIN [as write] (net.js:407)
at Object.runCommand (ads.js:1014)
at Object.readDeviceInfo (ads.js:295)
at EventEmitter.ads.adsClient.readDeviceInfo (ads.js:60)
at renderer.js:153

Any Ideas how to keep the connect open?

Thanks,
Jon

@PLCHome
Copy link
Collaborator

PLCHome commented Dec 16, 2019

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

  • click on Image and go to the ADS tab. Check the Enable ADS Server and also Create symbols. Download the new configuration and make sure you reboot your PLC. The reboot is only needed when you are using TwinCat 2.

  • Now add a static route to our Beckhoff PLC. The route should point to your server that will run the proxy application. It's also a good idea to add an extra static route that points to your local development device. This way you can test out the proxy from your development device too.

Attention

  • TwinCAT AMS Router doesn't allow multiple TCP connections from the same host. So when you use two AdsLib instances on the same host to connect to the same TwinCAT router, you will see that TwinCAT will close the first TCP connection and only respond to the newest. If you start the TwinCat System Manager and Node-Red ADS on the same PC at the same time, Node-Red will not run anymore. You can set up a second IPv4 on the PC and assign to this a ADS NET ID under Twincat

  • As ADS is transmitted over a TCP connection, there is no real time guarantee.

Setting Up an ADS Remote Connection

@JonFranklin301
Copy link
Author

Hi @PLCHome
I can confirm the ADS is enabled, Create symbols is checked and there is a route setup.
We have another client running on a different machine that uses the ADS .NET dll to read data from the project without any issues.

Using node-ads I am able to connect and read data correctly for about 10 seconds before the connection is disconnected.

Thanks,
Jon

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