Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now bad quality status received from sensors resets PLC connection. #84

Closed
wants to merge 1 commit into from

Conversation

edkb
Copy link

@edkb edkb commented Jul 16, 2019

No description provided.

@plcpeople
Copy link
Owner

Is this always the right thing to do? What about the case where a large number of values are being requested and one of them doesn't exist in the PLC, like a data block offset that doesn't exist? What is the issue that this commit fixes?

@edkb edkb closed this Jul 16, 2019
@edkb
Copy link
Author

edkb commented Jul 16, 2019

Sorry for not discussing the issue before. We had some problems here using the node red S7 library, that the PLC didn't reconnect properly after disconnecting (see st-one-io/node-red-contrib-s7#30). So I found that I could force it to reconnect when receiving bad quality values. If you can find a better solution we'll appreciate.

@gfcittolin
Copy link
Collaborator

Thanks @edkb for the PR and all the effort you put into it, but I also that the way it's done here can have other unintended implications. If we indeed need to trigger a reconnection, we could do it from the Node-Red Node, even though nodes7 should already reconnect when necessary.
Maybe we can discuss this further in the original issue.

@plcpeople
Copy link
Owner

I pushed a commit that takes some of the improvements from the nodepccc project for reconnecting that may help with your issue.

@edkb
Copy link
Author

edkb commented Jul 17, 2019

Thanks for the feedback guys. @plcpeople I tested with your update but unfortunately I didn't find any difference in the PLC behavior. @gfcittolin I don't know where this issue is located (Node Red Node or this S7 library), but the bad quality symptom comes from here and since we don't use this value it's still the only solution for our case. Anyway, it would be great if you find other way to know when the PLC is down.

@plcpeople
Copy link
Owner

@edkb @gfcittolin when Node-red (and your flow) receive "bad values" like in the trace reported on the original issue, what happens? Does it try again to request values? I think what is happening is that the bad packet coming from the LOGO is causing the connection to reset once, but then this doesn't happen instantly, and while you're waiting for it to reset, it returns bad values. That is why the fix in the PR worked - constantly re-triggering the reconnect will eventually return good values. But if you always request new values after you receive a reply from nodeS7 (with good or bad values) then it should work. Or is this not practical/possible?

@gfcittolin
Copy link
Collaborator

The Node-RED node always tries to read the values again, regardless of the quality of the result. It also even monitors whether the callbacks with results are being called, because of an issue we had in the past where callbacks weren't being called in some circumstances. So trying to read the values again is probably not the issue here.

@edkb I was taking another look on the log section you posted on the original issue, and, on that case, the issue was a packet timeout. How's your physical network between LOGO and your Node-RED instance? And what's the ping average to the PLC? If this is an issue, try increasing the timeout on the configuration at Node-RED, from the 1500ms default to something like 5000ms.

Other than that, I'm a bit out of clue without testing it, or checking the full logs, so if the suggestion above doesn't result to any improvement, we could try to arrange a proper way for testing/simulating the issue.

@edkb
Copy link
Author

edkb commented Jul 18, 2019

@gfcittolin I changed timeout but still no difference.
The physical layer is very simple, just the server connected to a switch and the PLC connected to the same switch. What is looking strange for me is that the logs are different when the Node Red starts with the PLC disconnected and when it disconnects after being connected once.
I'm posting the logs here again but with the full story: Started node red with the PLC unplugged, plug the PLC on the wallet, unplug the PLC and then plug it in again. It does reconnect, but it takes about 15 minutes.
PLC_log.txt

@gfcittolin
Copy link
Collaborator

The logs being different is something expected. Before the first connection happens we're on a different internal state, the read packets haven't been optimized yet, and so on. But if you look closely, the root cause is the same EHOSTUNREACH. This is the OS telling us it can't reach the IP address we've requested to connect to.
Does it keep throwing the same error EHOSTUNREACH for the whole 15 minutes?

@edkb
Copy link
Author

edkb commented Jul 19, 2019

Yes, it keeps sending this unreachable state log for a long time (15 min, maybe more, maybe less) until eventually reconnect.

@plcpeople
Copy link
Owner

If the host is unreachable, how does resetting the connection in nodeS7 on bad quality (with the modification in the PR) help anything connect any faster?

@edkb
Copy link
Author

edkb commented Jul 19, 2019

Because the host is actually reachable, the PLC was reconnected to the power, but the libraries doesn't detect that. So resetting the connection when the PLC is up and reporting bad quality works just fine.

@gfcittolin
Copy link
Collaborator

This library already performs reconnection in case of issues with the underlying socket, and this is why you're seeing EHOSTUNREACH multiple times. So I can't understand why/how triggering the same logic to reconnect may solve the issue, if it's the OS that reports EHOSTUNRECH to us. What's the underlying operating system?
Could you provide the full logs (not just sections of it) while the issue happens, along with a pinging log of it? Or then just a complete wireshark dump of it? I'm afraid we're just targeting the wrong problem

@gfcittolin
Copy link
Collaborator

You can also send the logs/dumps privately if that's a concern

@exvarkin
Copy link

exvarkin commented Aug 1, 2019

@edkb Can the 15 min time frame before the reconnect be adjusted? I haven't managed to find where the 15 min setting is coming from.

@edkb
Copy link
Author

edkb commented Aug 1, 2019

@exvarkin There's no setting to this, those 15 min its just a rough estimation that I counted manually in one of the tests, but it can take longer or shorter than that. Actually, it should be instantaneous, and why it is taking so long is really a good question.

@exvarkin
Copy link

exvarkin commented Aug 1, 2019

I see, I've seeing 15 min delay myself so I assumed it was configured that way somewhere.

In my case, the PLC is becoming unreachable, (Host running nodeS7 can't ping the PLC) for about 1-2min. But the nodeS7 connection always waits 15 min before resetting the connection automatically. I've manual reset the node script after the communication was back up (before the connection auto restarts) and can read the PLC. Was hoping for a way to shorten that delay while I try to figure out the root cause of my periodic communication issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants