Description:
I tested the connection management of nodes7 under Windows as well as under Linux. For the test I use keepalive. (Note: Under Linux I use the modul net-keepalive).
Environment:
1) Windows 10 Pro, Node@v8.11.4
2) Linux (Own Distribution, Kernel Version 4.9.75-rt60-preempt-rt), Node@8.11.4
Tests (Under Linux as well as under Windows.) :
Test case 1:
Nothing is done after the connection is established.
Cable is removed from PLC
After a while the cable is plugged in again.
Test case 2:
After connection is established, 'MB0' is read cyclically.
Cable is removed from PLC
After a while the cable is plugged in again.
Steps to Reproduce:
const NodeS7 = require('nodes7');
let NetKeepAlive = null;
try {
NetKeepAlive = require('net-keepalive'); // net-keepalive depends on the OS
} catch (er) {
console.log('Installation of Module net-keepalive failed. (OS=' + process.platform + ')');
NetKeepAlive = null;
}
const plc = new NodeS7({ debug: 1, silent: false });
const param = { port: 102, host: '192.168.0.111', rack: 0, slot: 2 };
const intervalReading = false; // Set Flag to true/false
plc.initiateConnection(param, (err) => {
if (typeof (err) !== 'undefined') {
console.log(err);
process.exit();
}
// Enable KeepAlive.
plc.isoclient.setKeepAlive(true, 3000);
if (NetKeepAlive) {
console.log('Set keepalive parameter for linux.');
NetKeepAlive.setKeepAliveInterval(plc.isoclient, 3000);
NetKeepAlive.setKeepAliveProbes(plc.isoclient, 5);
}
if (intervalReading) {
plc.addItems('MB0');
setInterval(() => {
console.log('Status: ' + plc.isoConnectionState);
plc.readAllItems((anythingBad, values) => {
if (anythingBad) {
console.log('SOMETHING WENT WRONG READING VALUES!!!!');
} else {
console.log(values);
}
});
}, 1000);
}
});
Expected Behavior:
Test case 1:
After successful connection establishment keepalives are exchanged every n sec.
If the cable is removed from the PLC, keepalives are not acknowledged
After a while Nodes7 changes isoConnectionState from 4 to 0 or 1 due to a reset.
Program ends.
When the cable is plugged in again nothing happens
Test case 2:
After successful connection establishment, cyclic communication starts.
If the cable is removed from the PLC, nodes7 attempts a reconnection.
nodes7 changes isoConnectionState after a while from 4 to 0 or 1 due to a reset
When the cable is plugged in again reconnection nodes7 starts
After a while cyclic communication starts again
Actual Behavior:
Overview:
Testcase
1
2
Windows
OK
OK
Linux
OK
Not OK
Detailed:
To Testcase 1 (windows): NodeS7 resets Program due to ECONNRESET
To Testcase 2 (windows): NodeS7 resets Program due to ECONNRESET, restarts communication again.
To Testcase 1 (linux): NodeS7 resets Program due to ETIMEDOUT
To Testcase 2 (linux): No reset of nodes7, state always at 4 due to missing ETIMEDOUT, but nodes7 restarts communication again.
I think the state should also go to 0 here.
Description: I tested the connection management of nodes7 under Windows as well as under Linux. For the test I use keepalive. (Note: Under Linux I use the modul net-keepalive).
Environment: 1) Windows 10 Pro, Node@v8.11.4 2) Linux (Own Distribution, Kernel Version 4.9.75-rt60-preempt-rt), Node@8.11.4
Tests (Under Linux as well as under Windows.) : Test case 1:
Test case 2:
Steps to Reproduce:
Expected Behavior: Test case 1:
Test case 2:
Actual Behavior: Overview:
Detailed: To Testcase 1 (windows): NodeS7 resets Program due to ECONNRESET To Testcase 2 (windows): NodeS7 resets Program due to ECONNRESET, restarts communication again.
To Testcase 1 (linux): NodeS7 resets Program due to ETIMEDOUT To Testcase 2 (linux): No reset of nodes7, state always at 4 due to missing ETIMEDOUT, but nodes7 restarts communication again. I think the state should also go to 0 here.