LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCPIP connection closed and reopening connection

I connected to another board using TCP Open Connection.vi and the used TCP Close Connection.vi and nothing more. IP address and ports are hard coded.  The first time I run my program the connection is made and closed and is verified by messages displayed on the remote board.  When I then run this program a second time within a few minutes, the connection cannot be opened again.  After playing around we found that we had to close the socket on the remote board or wait for a 5 minute time out period before opening the same connection with the LabVIEW program.  Is there a way to make a reconnect from LabVIEW after closing a socket without having to wait for the socket time out or having to close it at the remote board?
0 Kudos
Message 1 of 3
(4,074 Views)

This sounds like it is either an attempt to reuse a local port too soon or an issue with the remote end.

 

Are you specifying a specific local port for your connection? If you are don't. There is no reason to do that and it can cause issues with trying to reuse the connection too soon after closing it. Let the stack manage the local port for the connection. The TCP protocol does have a wait period (TIMEWAIT) before it can reuse a local port.If this is not the case then you will need to dig deeper.

 

Have you verified that the TCP-FIN packet is being sent to the remote end? You can do this using Wireshark to capture the packets and look for the TCP-FIN as well as the acknowledgements from the remote end. If the TCP-FIN is sent and not acknowledged either the packet is not reaching the remote end due to some routing problem or the remote end is not processing the message. If you are receiving the acknowledgements for the TCP-FIN packet then it is definitely a problem with your remote end. Is the remote side of the connection also written in LabVIEW? What are you trying to communicate with?

 

I have used the NI TCP VIs extensively and have not encountered the issue you are seeing. Try the above two suggestions and post back additional information if they didn't solve your problem.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 3
(4,064 Views)

I check again with Wire Shark and found I was not getting the FIN msg back from the remote site and corrected the code there. Problem solved!  Thanks for assistance...

0 Kudos
Message 3 of 3
(4,042 Views)