LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP Connection Won't Reconnect

I am using LabView 7.0 to read and write to 20 Watlow F4 controllers on a Windows XP machine with Dual processors, 1.5 GB of ram and two SCSI hard drives setup for RAID 1. Each controller is connected to a Tidal Engineering Gateway that allows me to use the Modbus TCP protocol. Each chamber is manipulated thorugh it's own loop independent of of the other chambers. So yes, I have 20 independent loops running. This minimized the time between updates to about 3.5 seconds and the system seems to handle the workload fine. The problem is that periodically a connection will drop out. And about half the time it is never able to reconnect. When the connection fails I close the connection wait 10 secs and attempt to reopen the connection. The is retried 3 more times with waits of 20,30 and 40 secs. If after the fourth time it still fails I stop trying to reconnect. This seems to happen most often when the command to the Gateway changes. Most of the time I am simply polling 32 different parameters, but periodically I need to be able to read and write to other parameters and therefore have to change the Modbus message accordingly. This seems to be when things go wrong the most often. I realize I took a brute force approach, but does anyone have any suggestions about how I can more readily reconnect? The only thing that seems to work is shutting down LabView and bring it back up and this seems to immediately fix the problem, but obviously means that I have to stop monitoring the other 19 chambers because the connection to one failed. Help? Thanks
0 Kudos
Message 1 of 4
(3,264 Views)

Hi Mike,

If I understand the problem correctly, you are not able to reopen a TCP connection on the same port after closing it. I found a link to an example program that might be worth taking a look at. I hope it helps.

Regards,
Chris J

http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B123AE0CBA58111EE034080020E74861&p_...

0 Kudos
Message 2 of 4
(3,249 Views)
I appreciate your help. I modelled my reconnection routine after that example. Now I think I need to explain a little further. I only have need to use the Open TCP connection, READ TCP and Write TCP VI's. I never create a listener. I simply send a message to the gateway using write TCP and then read back the response using Read TCP. I do not know if the Gateway would work if I created a listener. Is it worth using a listener instead of using the Read TCP?
0 Kudos
Message 3 of 4
(3,240 Views)
I think the best thing might be to post the relevant piece of code (one of the loops), or at least an image of it (no BMPs, please).
 
In any case, a listener waits for someone to "call" and then tells you that they called and gives you their address. It doesn't pass information and you will still need to use the read and write VIs. Also, it can only help if your gateways can call. In any case, all that example shows is how to use the close VI.
 
The basic conception should be "try to connect until you succeed (loop #1), then read\write until there is an error or consecutive error (loop #2), then close the connection and repeat unless stopped (external loop, #3)". You can see an example of something like this here.

___________________
Try to take over the world!
0 Kudos
Message 4 of 4
(3,228 Views)