LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP Communication with Python Datasocket Server Read Timeout

Solved!
Go to solution

I am trying to connect to a socket server in python, see the attached code. I am able to write and read the necessary data, but LabVIEW throws an error code LabVIEW: (Hex 0x38) The network operation exceeded the user-specified or system time limit.

 

More or less I am trying to send strings to the Python server, calculate the information, and pass it back to LabView through TCP. My timeout is set to 10 seconds, and the number of bytes is 500, which is just set to hold all data that could potentially come across from the server.

 

Using LabVIEW 2020 if that makes any difference.

 

Any idea why this error keeps popping up when the data is being received? And/or how to mitigate it?

 

 

Download All
0 Kudos
Message 1 of 5
(1,186 Views)
Solution
Accepted by carq

Are you making sure you send exactly 500 bytes back?

You don’t wire the mode input on the TCP Read so it will operate in Standard mode. You should probably make sure to append CR LF to the string and make sure the string itself doesn’t contain this sequence and then use the CRLF mode on TCP Read. There are other methods but this one would seem the most easy.

Rolf Kalbermatter
My Blog
Message 2 of 5
(1,178 Views)

I am sending a variable number of bytes back, depending on what is currently needed in my software.

 

Changing the mode to immediate on TCP Read worked! Thank you!

0 Kudos
Message 3 of 5
(1,174 Views)

Immediate would work as long as you make sure that the other end sends the ENTIRE response in a single write(), and it is not a huge amount that could get fragmented. Immediate basically says: return as soon as there are any bytes present to return and only wait for the timeout if no bytes at all arrive. So if your message gets fragmented, the first fragment arriving will cause the function to return with your partial data and the next read will return with the rest (or next fragment). That's usually not what you want. 

Rolf Kalbermatter
My Blog
Message 4 of 5
(1,167 Views)

I will most definitely keep that in mind as my software grows in size. I appreciate your assistance!

0 Kudos
Message 5 of 5
(1,142 Views)