st-one-io / node-red-contrib-s7

A Node-RED node to interact with Siemens S7 PLCs
GNU General Public License v3.0
111 stars 58 forks source link

Connection keeps dropping when no variables are configured #31

Closed gfcittolin closed 5 years ago

gfcittolin commented 5 years ago

When an endpoint is configured without any variables (e.g. when you want to validate if your connection settings are right), The connection is established, but the logs show that the connection keeps dropping:

29 Oct 11:50:44 - [info] Starting flows
29 Oct 11:50:44 - [info] Started flows
29 Oct 11:50:44 - [info] [s7 endpoint:4d6b761f.86ba18] Initiating connection to PLC
[11781,217660357] Initiate Called - Connecting to PLC with address and parameters:
[11781,217715100] { host: '192.168.15.211', port: '102', rack: '0', slot: '1' }
[11781,218881427] Connection cleanup is happening
[11781,218991828 192.168.15.211 S1] Clearing read PacketTimeouts
[11781,219063620 192.168.15.211 S1] Clearing write PacketTimeouts
[11781,219501763 192.168.15.211 S1] <initiating a new connection Mon Oct 29 2018 11:50:44 GMT-0300 (-03)>
[11781,219541389 192.168.15.211 S1] Attempting to connect to host...
[11781,224300581 192.168.15.211 S1] TCP Connection Established to 192.168.15.211 on port 102
[11781,224368516 192.168.15.211 S1] Will attempt ISO-on-TCP connection
[11781,224725072 192.168.15.211 S1] Using rack [0] and slot [1]
[11781,232378453 192.168.15.211 S1] ISO-on-TCP Connection Confirm Packet Received
[11781,288332707 192.168.15.211 S1] Received PDU Response - Proceeding with PDU 240 and 3 max parallel connections.
[11781,288871241] Translation OK
[11781,790707556 192.168.15.211 S1] Reading All Items (readAllItems was called)
[11781,791677224 192.168.15.211 S1] Adding or Removing { arg: [], action: 'add' }
[11781,792208897 192.168.15.211 S1] Adding 
[11781,793870781 192.168.15.211 S1] Calling SRP from RAI
[11781,794658986 192.168.15.211 S1] SendReadPacket called
29 Oct 11:50:51 - [warn] [s7 endpoint:4d6b761f.86ba18] No response from PLC, restarting communication
29 Oct 11:50:51 - [info] [s7 endpoint:4d6b761f.86ba18] Closing connection to PLC
[11787,307025893] We Caught a read/write error ECONNRESET - will DISCONNECT and attempt to reconnect.
[11787,307597669] ConnectionReset is happening
[11787,308262371] ConnectionReset is happening
29 Oct 11:50:51 - [info] [s7 endpoint:4d6b761f.86ba18] Initiating connection to PLC
[11787,309263433] Initiate Called - Connecting to PLC with address and parameters:
[11787,309359224] { host: '192.168.15.211', port: '102', rack: '0', slot: '1' }
[11787,309582364] Connection cleanup is happening
[11787,309682397 192.168.15.211 S1] Clearing read PacketTimeouts
[11787,309770658 192.168.15.211 S1] Clearing write PacketTimeouts
[11787,310069378 192.168.15.211 S1] <initiating a new connection Mon Oct 29 2018 11:50:51 GMT-0300 (-03)>
[11787,310145058 192.168.15.211 S1] Attempting to connect to host...

This is probably happening because we're calling readAllItems() without any configured variables. Maybe we can check if there are configured variables before performing the cyclic read process, so we can evict this kind of error.