Apollon77 / node-mbus

Nodejs mbus module
MIT License
21 stars 15 forks source link

Add some flags to `getData` to avoid lengthy time-outs #102

Closed sjlongland closed 1 year ago

sjlongland commented 1 year ago

It appears the problem in Issue #101 is two-fold:

  1. TCP time-out being set to an unreasonably long value unwittingly (as it was interpreted as being a connection establishment time-out, not a request time-out)
  2. two unexplained network pings, followed by a ping meant to work around a specific device, all of which timed out

We can likely fix (1) by documentation -- leave the default of 4 seconds, but provide some guidance as to how this should be tuned, and most importantly, what the time-out is used for.

For (2), an options parameter is added to getData. This is optional, and if omitted, we assume default behaviour, which to avoid breaking existing networks, maintains the old behaviour.

options.pingFirst controls the behaviour first established in https://github.com/rscada/libmbus/pull/95 -- if pingFirst is false, we skip the initial pings (including those done in the undocumented init_slaves). The default is true in case existing networks using node-mbus rely on this behaviour.

Possibly breaking changes