ads-client 1.14.0 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.14.1] - 13.09.2022
8
+ ### Changed
9
+ - Bug fix: Connecting to local router failed with ECONNREFUSED error on Node.js version 17 and newer
10
+ - See [https://github.com/nodejs/node/issues/40702](https://github.com/nodejs/node/issues/40702)
11
+ - Fixed by using `127.0.0.1` instead of `localhost`
12
+
13
+
7
14
  ## [1.14.0] - 23.07.2022
8
15
  ### Added
9
16
  - Created end-to-end testing for the library using Jest
package/README.md CHANGED
@@ -1713,8 +1713,6 @@ Solution:
1713
1713
  Solution:
1714
1714
  - See [this issue comment](https://github.com/jisotalo/ads-client/issues/51#issuecomment-758016428) by hansipete how to do it.
1715
1715
 
1716
-
1717
-
1718
1716
  ### A data type is not found even when it should be
1719
1717
 
1720
1718
  If you use methods like `convertFromRaw()` and `getDataType()` but receive an error similar to `ClientException: Finding data type *data type* failed`, make sure you have really written the data type correctly.
@@ -1756,6 +1754,16 @@ Another option is to use setting `bareClient: true` (since v.1.13.0). However, w
1756
1754
 
1757
1755
  I would suggest to use ads-client normally without any special settings. If the target is at config mode, use separate client instance to start it, and the again the normal instance to connect to a running system. This way the client works the best.
1758
1756
 
1757
+ ### Getting a message `Ads notification received but it has unknown notificationHandle (**). Use unsubscribe() to save resources.`
1758
+
1759
+ Possible reasons:
1760
+ * You have created notifications (subscriptions) using `subscribe()` and then closed the Node.js application without unsubscribing them first (TwinCAT still sends the data)
1761
+ * You are connecting without router (providing directly the target IP as router address) and you have other connections too like TwinCAT XAE running. See issue: https://github.com/jisotalo/ads-client/issues/85
1762
+
1763
+ Solution:
1764
+ * When closing application, first unsubscribe from all notifications using `unsubscribeAll()`
1765
+ * Use router instead of direct connection, see https://github.com/jisotalo/ads-client/issues/85#issuecomment-1193098519
1766
+
1759
1767
  # Automatic testing
1760
1768
  Since version 1.14.0 the library has automatic testing using Jest. Idea is to run the tests before updates to make sure everything works OK (this should have been done much earlier...)
1761
1769
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ads-client",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
4
4
  "description": "Beckhoff TwinCAT ADS client library for Node.js (unofficial). Connects to Beckhoff TwinCAT automation systems using ADS protocol.",
5
5
  "main": "./src/ads-client.js",
6
6
  "scripts": {
package/src/ads-client.js CHANGED
@@ -61,7 +61,7 @@ class Client extends EventEmitter {
61
61
  * @property {boolean} [readAndCacheDataTypes=false] - If true, all PLC data types are cached during connecting. Otherwise they are read and cached only when needed - Optional (**default**: false)
62
62
  * @property {boolean} [disableSymbolVersionMonitoring=false] - If true, PLC symbol version changes aren't monitored and cached symbols and datatypes won't be updated after PLC program download - Optional - Optional (**default**: false)
63
63
  * @property {number} [routerTcpPort=48898] - Target ADS router TCP port - Optional (**default**: 48898)
64
- * @property {string} [routerAddress=localhost] - Target ADS router IP address/hostname - Optional (**default**: localhost)
64
+ * @property {string} [routerAddress=127.0.0.1] - Target ADS router IP address/hostname - Optional (**default**: 127.0.0.1)
65
65
  * @property {string} [localAddress='(system default)'] - Local IP address to use, use this to change used network interface if required - Optional (**default**: System default)
66
66
  * @property {number} [localTcpPort='(system default)'] - Local TCP port to use for outgoing connections - Optional (**default**: System default)
67
67
  * @property {string} [localAmsNetId='(from AMS router)'] - Local AmsNetId to use - Optional (**default**: From AMS router)
@@ -91,7 +91,7 @@ class Client extends EventEmitter {
91
91
  readAndCacheDataTypes: false,
92
92
  disableSymbolVersionMonitoring: false,
93
93
  routerTcpPort: 48898,
94
- routerAddress: 'localhost',
94
+ routerAddress: '127.0.0.1',
95
95
  localAddress: null,
96
96
  localTcpPort: null,
97
97
  localAmsNetId: null,
@@ -145,6 +145,12 @@ class Client extends EventEmitter {
145
145
  this.settings.targetAmsNetId = '127.0.0.1.1.1'
146
146
  }
147
147
 
148
+ //Checking that router address is 127.0.0.1 instead of localhost
149
+ //to prevent problem like https://github.com/nodejs/node/issues/40702
150
+ if (this.settings.routerAddress.toLowerCase() === 'localhost') {
151
+ this.settings.routerAddress = '127.0.0.1'
152
+ }
153
+
148
154
  /**
149
155
  * Internal variables - Not intended for external use
150
156
  *