You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is usually stopped after some failed requests either 2023-06-29T06:41:29.365Z startGettingData Timed out ETIMEDOUT
or 2023-06-29T06:33:26.760Z startGettingData Port Not Open ECONNREFUSED
or
2023-07-06T05:27:19.498Z connect ETIMEDOUT {IP}:{PORT} -110
HMI continues working correctly. Our system gets the responses after restarting the PLC or plugging out/in the LAN cable.
It issues accrues when code is deployed in AWS ECS. During the local deployment, we didn't face it yet.
I attempted to read both individual registers and multiple registers simultaneously. The issue persists. Interestingly, even though the requests count to PLC is lowered drastically, the issue arises more frequently in the case of reading several registers at once.
const ModbusRTU = require('modbus-serial');
const { setTimeout } = require('timers/promises');
let client = new ModbusRTU();
// check error, and reconnect if needed
async function checkError() {
console.log(new Date().toISOString(), "we have to reconnect");
// close port
await client.close();
await setTimeout(5000);
// re open client
client = new ModbusRTU();
await setTimeout(2000);
await connect();
}
// open connection to a serial port
async function connect() {
// if client closed, open a new connection
console.log(new Date().toISOString(), `Trying to connect: ${process.env.PLC_IP}:${process.env.PLC_PORT}`);
try {
await client.connectTCP(process.env.PLC_IP, { port: Number(process.env.PLC_PORT) });
await setClient();
console.log(new Date().toISOString(), "Connected");
} catch (error) {
console.log(new Date().toISOString(), error.message, error.errno);
await checkError();
}
}
async function setClient() {
// set the client's unit id
// set a timout for requests default is null (no timeout)
await client.setID(1);
await client.setTimeout(10000);
}
module.exports = {
client,
connect,
checkError,
};
Could you kindly provide me with guidance on the appropriate direction to dig? Is it something related to latency or PLC capabilities? Or maybe there are some subtleties which are not considered in the code.
The text was updated successfully, but these errors were encountered:
It is usually stopped after some failed requests either
2023-06-29T06:41:29.365Z startGettingData Timed out ETIMEDOUT
or
2023-06-29T06:33:26.760Z startGettingData Port Not Open ECONNREFUSED
or
2023-07-06T05:27:19.498Z connect ETIMEDOUT {IP}:{PORT} -110
HMI continues working correctly. Our system gets the responses after restarting the PLC or plugging out/in the LAN cable.
It issues accrues when code is deployed in AWS ECS. During the local deployment, we didn't face it yet.
I attempted to read both individual registers and multiple registers simultaneously. The issue persists. Interestingly, even though the requests count to PLC is lowered drastically, the issue arises more frequently in the case of reading several registers at once.
PLC Model:
The following is my setup:
main.js
plc.js
redis/index.js
handlers.js – getting several register values at once
handlers.js – getting one by one example
Could you kindly provide me with guidance on the appropriate direction to dig? Is it something related to latency or PLC capabilities? Or maybe there are some subtleties which are not considered in the code.
The text was updated successfully, but these errors were encountered: