LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP Read does not detect network conncetion closed error (66)

Solved!
Go to solution

Hi Dear all,

Instead of LAN i am using WLAN to connect PC and mobile. All communication read and write operations are performing ok. But the only problem i am facing is that once i disconnect network connection from mobile my labview TCP read operation does not detect it and only timesout at its specified interval. Although for Bluetooth network connection if i disconnect from mobile then BT read detects it as network conncetion closed by peer error (66).

 

Can someone help me on this.

Thanks & Regards

awais qureshi

0 Kudos
Message 1 of 13
(4,794 Views)

Awais,

 

please post some example code showing why this is an issue for you.

 

TCP Read tries to read from the session. It does not check if the session is still valid; this has to be done using error handling.

An example is shown in the "TCP Communicator - Active.vi" in the loop in the bottom: It checks for time out in order to cancel communication attempts.

You would extend this example to try a reconnect to the server. Of course, the server itself has to "rearm" itself first.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 13
(4,786 Views)

Hi Dear Norbert,

Thanks for reply. I am doing the error handling like the same way and terminating the while loop for TCP Read but the problem is that my TCP Read only gives timesout (56) error. Even if i close the connection of WLAN from mobile during that timeout period. It closes still after timeout period. Whereas same was not in case of BT.

 

I think may be it is due to the reason that Labview has drivers for BT whereas for WLAN/LAN it uses general TCP protocols.

 

Have you disconnected the Connection before the timeout period expiers? And you used LAN or WLAN?

 

Regards

awais qureshi

0 Kudos
Message 3 of 13
(4,775 Views)

Awais,

 

that's what was indicating: you have to check for time outs as well and react as desired (for your application).

 

I have not tested WLAN yet, so i cannot give any comment of wether loosing the connection should result in time out (56) vs. connection closed (66) is ok or not.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 13
(4,771 Views)

Thanks Norbert

OK, then for LAN when did you get connection closed (66) error? Is it by just unplugging the LAN cable and during that also time out period is not over, then 66 error is prompted.

Regards

awais

0 Kudos
Message 5 of 13
(4,766 Views)
Solution
Accepted by topic author Awais_Qureshi

Hi Awais, 

 

The behavior that you are seeing is expected for TCP protocal because the device will timeout while it is looking for the connection to close the connection.  This Wikipedia article explains the way that TCP protocal works in relation to a four way handshaking procedure that TCP performs in order to close a connection.  I hope this helps!

 

Kim

Applications Engineer
National Instruments
0 Kudos
Message 6 of 13
(4,755 Views)

Hi Dear Norbert,

I am still waiting for your reply. Whats error you get once you unplug LAN cable? i am unable to understand how to detect Disconnection during Read Time out. Kindly help me in this.Thanks

 

Dear VT Kim,

I studied your recommended article but which way Labview handles TCP close connection then. i am unable to understand how to detect Disconnection during Read Time out. Kindly help me in this.

Regards

awais qureshi

0 Kudos
Message 7 of 13
(4,721 Views)

@awais Qureshi wrote:

Hi Dear Norbert,

I am still waiting for your reply. Whats error you get once you unplug LAN cable? i am unable to understand how to detect Disconnection during Read Time out. Kindly help me in this.Thanks

 

Dear VT Kim,

I studied your recommended article but which way Labview handles TCP close connection then. i am unable to understand how to detect Disconnection during Read Time out. Kindly help me in this.

Regards

awais qureshi


I have not tested it but more likely than not you would get an error 59 when the network cable is unplugged. Error 66 is for when the network is still up and you attempt to communicate on an established connection that has been closed by the other side. This is not an error that you will se from a TCP read very often.

 

Also, please keep you related question in a single thread rather than starting multiple threads for the same topic.



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 8 of 13
(4,705 Views)

Thanks Mark,


You can't unless the other side of the connection explicitly sends a TCP-RST or TCP-FIN. If neither of these are sent there is no way for the your TCP-Read to detect the connection has been closed. This is not an issue with LabVIEW but how the TCP protocol works


 

But for the Bluetooth VIs if i disconnect BT connection from mobile during read timeout interval, then it does give me 66 error and quit the read process. So can we have thing like this for TCP VIs or its a limitation for TCP as its general purpose VIs not for specific network.

 

Regards

awais qureshi

0 Kudos
Message 9 of 13
(4,693 Views)

I haven't looked at the BT protocol that closely but within TCP you will generally not see this behavior. TCP is desigend to actually survive breaks in the network connection (such as a device switching APs in a wireless network or a break in the network somewhere between the two ends of the connection.) As such a connection can effectively be closed with no notification. If the all the data has been acknowledged between the two ends it is possible a connection can be silently closed. Therefore you need to wite your application such that it handles timeouts and can use these as an indication the connection has been closed. In addition, you can write the application layer to include messages that provide status information about the state of the connection and allow new TCP connections to be established in the event one gets closed.



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 10 of 13
(4,689 Views)