09-01-2021 01:50 AM
Hi,
I'm communicating between cRio and PC using shared variables. Connection is working fine, but I'd like to improve the functionality when connection is lost between the two.
When I disconnect the Ethernet cable between cRio and PC, my program notices this by monitoring errors.
When I connect the cable, clear the errors and try to open connection after a while, the program can establish connection, but it takes some time, maybe 30-60s from connecting the cable.
Are there any actions that I could do to make re-connection faster?
Thanks.
09-01-2021 05:59 AM
My honest advice: Stop using Network Published Shared Variables. They are slow, very insecure (anybody on the network could update them), and have caused me so many very weird race conditions. Instead, use a direct TCP connection to pass data back and forth between the cRIO and PC. I do this with a loop specifically for this communication on each side an use a queue or User Event to pass the data on to whoever needs it. The loop can detect a disconnection (have an error) and close the connection and go back to trying to establish a connection (cRIO as the server uses the TCP Create Listener). Assuming you are using static IP addresses, I have had disconnections and be able to reconnect seemingly as soon as I reconnect the cable.
09-01-2021 06:35 AM
In my case there is no possibility for security threats but there's also no possibility to change to direct TCP at this point.
I just would like to know if there is any way to get reconnection a bit faster when using shared variables. Is there some reset feature/process or something like that, which would speed up the reconnection?
09-01-2021 09:03 AM
Are Shared variables the same as network shared variables? (I haven't used them), if so, there's a Read with Timeout that you can use.