stream
stream copied to clipboard
GatewayTargetDeviceFailedToRespond with Modbus TCP Client
If I have my polling interval too fast, I get this error. The client/server (master/slave) are in very close proximity on an uncongested network.
modbus.tcp.connect(502, "192.168.2.165", { debug: null, retries: 0, retry: 3000 }, (err, connection) => {
// do something with connection
setInterval(function () {
connection.readHoldingRegisters({ address: (sqlResult[0].MBAddr - 40000), quantity: 2 * sqlResult.length, extra: { unitId: 1 } }, (err, res) => {
if (err) {
console.log(Date.now() + ": " + err);
}
for (i = 0; i < sqlResult.length; i++) {
convert_to_32(res.response.data[2 * i].readUIntBE(0, 2), res.response.data[2 * i + 1].readUIntBE(0, 2), 'ModbusData[' + i + ']');
}
});
}, 200);
});
Very randomly, I get "Error: GatewayTargetDeviceFailedToRespond:"
I had the same error on a Siemens PAC2200 when I queried multiple registers in parallel. You need to increase the time between the requests.
In my opinion this is not a bug of node-modus but something that is device related and that you need to deal with.