LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP error 62

Solved!
Go to solution

Hello! There were a few topics regarding this error and looked through them and actually none of had a solution or at least none for me. In one of the other thread a regular user meant like "perhaps Windows has closed the socket due to inactivity". I wouldn't know that Windows does that. And most of all, why?

 

We have used the TCP VIs in quite a few solution and never had this. What, in my case, might be different to what we did before: between opening the socket and sending the first message some seconds pass. As it seems, this is the reason. In the attached test VI when they delay is 0 - 4 seconds, it works as expected. With 5 seconds, either error 66 or 62 would come. 

 

Is this normal? Is this Windows or LabView? 

 

Windows has a connection timeout, but it's not rigid. Atm. I don't know how to determine it, but I don't think it's only 4 second. There is also a keep-alive timeout in  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters, which is set to 30000 (presumably milliseconds). Another place to look at are the network adapter settings, but there are none regarding timeouts.

0 Kudos
Message 1 of 13
(1,611 Views)
Solution
Accepted by MaSta

Hi MaSta,

 

most devices I worked with maintain their own "Keep TCP alive" timeout setting. Most often I configure them to "never timeout" (or "keep alive forever") when possible.

Example:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 13
(1,605 Views)

Case closed. The remote socket (here: one of our products) would close the connection after a variable timeout. I know that and totally forgot. 

0 Kudos
Message 3 of 13
(1,572 Views)

While your answer explains the error you did I would actually consider Geert’s answer as much or more the solution as he pointed you correctly to the fact that this is a device specific issue. Why people first suspect LabVIEW or Windows to be the culprit rather than their device always amazes me!

If Windows was the problem it would be a firewall issue and those usually simply prevent connections, so the Open function would already timeout. LabVIEW itself does very little of these below the surface beyond what the actual function is required to do to work properly!

Rolf Kalbermatter
My Blog
Message 4 of 13
(1,546 Views)

Right. Now that you say that I realized that we wrote "device", not interface. 

 

The device would now be set up to not close the connection anymore, but then the next problem comes up. Error 1 from the TCP Write VI which isn't documented in the LabVIEW help.

 

The code in which error 1 occurs is split. One VI opens the socket and passes the handle to a sub VI. I verified that the handle has the same value once it arrives the sub VI and where it's used for TCP Write. There it would cause error 1. I counter-tested the same thing in Docklight where writing and reading ModBus RTU frames over Ethernet works fine. Then I turned the VI that turns off the timeout into a test VI to recreate the split where the handle is converted to variant and back. It still works fine. On the internet there is an explanation for error 1.

0 Kudos
Message 5 of 13
(1,497 Views)

Error 1 is very much documented: It is the argument error. For VIs with refnums it usually means that the passed in refnum isn’t valid (anymore).

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 13
(1,488 Views)

OK, well, it's not documented in the list of TCP errors I wanted to say.

 

Like I wrote, I verified that the handle number comes correctly out of the conversion and that the device doesn't close the connection anymore. Else it would be error 62. https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000wziACAQ&l describes a possible reason, but I don't see that in my code happening. The handle goes into a variant which is part of a cluster and in the sub VI vice versa. I modified the test VI using the cluster now:

MaSta_0-1689251652312.png --> this also works, but still not in the other code with the sub VI. The content of the ComRef cluster element doesn't change until the sub VI is called. The handle arrives, but if it's still valid or not - how to check?

0 Kudos
Message 7 of 13
(1,472 Views)

As an alternative to pass the "connection ID" to the cluster I now used a global variable. Same result, error 1.

MaSta_0-1689254336151.png    

MaSta_1-1689254366369.png

MaSta_2-1689254415426.png

 

 

0 Kudos
Message 8 of 13
(1,458 Views)

LabVIEW refnums handling through globals is ugly and facilitates one other problem. The lifetime of all LabVIEW refnums is managed by the lifetime of the top level VI in whose hierarchy the refnum was created. Once that top level VI goes idle all the refnums created in its hierarchy are auto closed! The NaN/Is Not a Refnum correctly indicates if a refnum is still valid. 

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 13
(1,454 Views)

Here is an example of that. Start the Server, then Start Call. If you stall the data flow in Write, you will get error 1 during TCP Write.

Download All
0 Kudos
Message 10 of 13
(1,447 Views)