S7in problem offline-connecting indefinitely

Good morning. I have a problem with Node-RED and S7in nodes.
Sometimes the nodes stay Offline/Connecting indefinitely (but PLC is communicating S71200) and I have to restart the Node-red service by hand. Is there any way to prevent this from happening? Failing that, how to programmatically restart node-red from node-red itself detecting the status of a s7in node?
Thanks in advance!

I have seen this behavior (continuous restarts) but only on old hardware Siemens IOT2040 where I couldn't install latest S7 node version so I assumed this was node issue, because I've never seen this issue with latest nodeS7 version.

Where are you running nodered?

Thanks Karolis by the answer. Node-RED is running in a server with RED HAT ENTERPRISE LINUX. Version of node s7 is the latest (3.1) and plc 1212C.

The error in console is Timeout connecting to the transport and nodes reading variables are in offline and connecting cyclically. I connect to the plc with TIA PORTAL and is running and communicating perfectly. I restart node-red service and nodes are online. By one side I increased the timeout (from 2000 ms to 30000 ms) but i dont know if it is the reason.

I had this issue, when I tried to deploy new variables. For you, it just drops connection and leaves it like that?

I don't have access to s7 online installation, so can you attach Status node and check if status node grabs changes when connection drops?

Do you have more services that connect to this PLC via PUT/GET?

yes, i dont know if connection drop o what happens but node S7in remain offline/connecting.
I did a workarround catching Status of connection (offline) and restarting node-red.service with Exec command node "sudo -S systemctl restart nodered.service" (for the moment but i think it is to use a sledgehammer to crack a nut).
By the other hand i dont have more services via PUT/GET. We have an OPC SERVER reading variables but i don't know if needs put/get.