TCP Connection lost in between TCP read operation

Hi all,
                Is there any method to check whether TCP connection is lost ? Actually in my program server may need to read the data for 44 minutes & i want to know that while reading say after 20 minutes connection is lost for unknown reasons. In that condition i should make sure that connection is estalished / lost. If in between this happens than i should inform user the same.
Any implementation of this type. 
Kudos are always welcome if you got solution to some extent.
I need my difficulties because they are necessary to enjoy my success.
--Ranjeet

Ranjeet_Singh wrote:
Hi all,
                Is there any method to check whether TCP connection is lost ? Actually in my program server may need to read the data for 44 minutes & i want to know that while reading say after 20 minutes connection is lost for unknown reasons. In that condition i should make sure that connection is estalished / lost. If in between this happens than i should inform user the same.
Any implementation of this type. 
There is no direct method other than the results of transmitting/receiving data. If you get an error 66 that would indicate that the connection has been closed by the other side. However, you will not get this until you try to send/receive data. If you are receiving data continuously you can looki for a timeout error (error 56). You may also get an error 52. The end result is that you need to check the error codes and then take whatever action you deem necessary.
Mark Yedinak
"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot

Similar Messages

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

    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
    Solved!
    Go to Solution.

    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
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Detecting Error #59 while using TCP Read.vi

    I am using the TCP Read.vi to read data from a TCP connection. However, I need to know from the vi when the connection is lost, dropped, or reset. According to LabVIEW help, this should return back to me as Error #59. However, when I purposefully drop the connection on the server side, the TCP Read.vi does not return any errors.

    Here is my example. Its a small vi that simulates what I am trying to do. Let me know if you have questions.
    Attachments:
    TCP_Example.llb ‏159 KB

  • Error code 1 on tcp read

    Hello,
    I've been trying for quite some time to get a computer that acquires data and stores it to an array to send the data to another computer via TCP/IP using a crossover cable. The two computers send commands and information back and forth to each other using UDP, but to simplify things I wanted to use TCP/IP since the files are too large to be sent in one packet, and I don't want to worry about ensuring they're arriving in the proper order. Anyway, the connection opens fine, but I can't get any data through. At first I had no size specified on the read operation, so I thought that must be the problem, though neither of the computers experienced any errors despite the fact that the receiving computer received nothing. So when I realized I had forgotten to specify a size for the packet, I just created a constant for the purpose of testing the transfer. I created the constant by right clicking he size terminal and choosing create constant. Now when the code reaches this point in the code I get an error 1, and I'm not really sure why. Any ideas?
     Thanks,
    -Steve

    In the time I've spent debugging, I've been checking very carefully to ensure the connection isn't being closed (and that it's being opened), but I'll double check next time I get the chance. I highly doubt that Labview is releasing the connection on its own, because there are various connections to devices on the other computer that are kept the same way, and the code of the two machines is very similar.
    As far as the details leading up to the error, basically there is an initialization state in the main code, which opens all the necessary connections. The code does not leave this state until the TCP connection has been established with the other computer. The code then sends commands to the other computer via UDP to either tell it to take data or to see if the data has been already taken. Once it has been detected that the data has been taken, the code tries to read the data over the TCP connection after sending the command to the other computer to send it. The other computer is receiving the send command, and seems to think that the data is being sent with no problems. The TCP connection is never closed until an exit button is clicked in the program.  So unless Labview is dropping the connection of its own accord while the other actions are being taken, connecting with the program and trying to use it to read data should be all that is necessary to generate the error.
    I should get a chance to do more testing tomorrow, so I'll post what I come up with then. 
    Thanks for the suggestions!
    -Steve

  • TCP Read Error Code 1

    I met a problem in using "TCP Read" in LabView;
    First I use "TCP Open Connection" building connection successful with a instrument; and seem the connection ID as the global,equal to a "TCP Network Connection Refnum";
    Then I use the global as the connection ID,and use "TCP Write" send a command to a instrument;and use "TCP Read" Receive the instrument return message;this time a 56 error occurs,it is normal.
    But after I use this method Send/Receive two times successfully,when i use "TCP Read" receive message, the error 1 occurs,and nothing received.
    In each TCP operation,use the global "TCP Network Connection Refnum" as the "Connection ID" input.
    someone can tell me,why does it occur?

    JiangYu wrote:
    > I met a problem in using "TCP Read" in LabView;<br>First I use
    > "TCP Open Connection" building connection successful with a instrument;
    > and seem the connection ID as the global,equal to a "TCP Network
    > Connection Refnum";<br><br>Then I use the global as the connection ID,
    > and use "TCP Write" send a command to a instrument;and use "TCP Read"
    > Receive the instrument return message;this time a 56 error occurs,it is
    > normal.<br><br>But after I use this method Send/Receive two times successfully,
    > when i use "TCP Read" receive message, the error 1 occurs,and nothing received.
    > In each TCP operation,use the global "TCP Network Connection Refnum"
    > as the "Connection ID" input.<br><br>someone can tell me,why does it occur?
    Ouch, globals! That is usually the first sign of a bad application design.
    For the rest just watch out. LabVIEW refnums are garbage collected
    whenever the VI hierarchy which opened them goes idle (stops executing).
    So Executing a VI which Opens the TCP refnum and writes it into a global
    and then quits and then executing another VI which tries to use that
    refnum from the global will simply fail with error 1 as the refnum has
    been already automagically closed and is therefore invalid.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Error 56 occurred at TCP Read in MB Ethernet Receive.vi

    My sensor uses MODBUS TCP and operates as a slave device.  Currently I'm using Labview 7.1 on my PC and would like to communicate w/ sensor as a Master.  I downloaded MODBUS library from ni developer zone.  I want to read 14 discrete outputs (coils).  I believe MB Ethernet Master Query.vi is most appropriate to use for my application.  I put this block into my *.vi inside of a while loop, hooked up the connection ID, configured it with address start/quantity, and ran.  The error I got says: "Error 56 occurred at TCP Read in MB Ethernet Receive.vi->MB Ethernet Master Query.vi->...*.vi".  I have confirmed that TCP is working with Labview because I can receive other non-MODBUS sensor data from my device via TCP/IP using a different *.vi I created.  However this data is received though a different port than the typical 502 MODBUS port.  I have also confirmed MODBUS is working on my device using a 3rd party Polling Utility that reports register status.
    I currently do not have NI-VISA 3.0.1, VISA Server 3.0.0, or Measurement & Automation Explorer (MAX) version 3.1.1 installed on my PC.  Do I absolutely need these products to do what I need to do?
    Any thoughts why I am not able to get this setup working?
    Also, I am embarking on developing several MODBUS applications after this.  Would it be a good idea to upgrade my version of Labview to gain more MODBUS functionality w/ Labview?  I'm somewhat new to Labview and am a little confused on which products would really help me for working on MODBUS applications and if those products are compatible with my 7.1 version.

    Hi cwallis2,
    If you  can use  TCP/IP in Labview then you should be okay as far as that is concerned.  The Ethernet Modbus VIs use LabVIEW TCP VIs underneath; the Serial Modbus VIs use VISA underneath.  So unless you want to try the serial VIs if that's a possibility, then you should be okay without VISA.
    The error 56 is a time-out error and is generated when an operation
    exceeds the user-specified time limit. This error is caused by the
    LabVIEW code not receiving a network response in the defined time
    limit. The default time-out limit is 5 seconds, which should be enough,
    although you can increase this time-out value as an input for the MB
    Ethernet Master Query.vi. Since you get the time-out when you are
    reading instead of the initialization lets us know that you are able to
    open the TCP port correctly.
    What is the address you entering into the MB Ethernet Master Query.vi in the Modbus Command constant?  You may need to use relative addressing instead of absolute addressing, or vice versa. 
    Hope this helps!
    Adam W
    Applications Engineering
    National Instruments 

  • Setting TCP Read timeout value?

    How do I choose a timeout value for a TCP read function?
    I'm receiving data from a server at a rate which varies between 40 and 140 Hz (normally 120 Hz), there is no handshaking and at any set transmission rate it appears that the network load causes the rate to fluctuate slightly.
    All I have been able to do so far is plot a frame number that is received in my data and fiddle with the buffer mode and timeout until I get the least dropouts. At 120Hz 5ms works best with a standard buffer, surprisingly 8ms is poorer.
    I am using a producer consumer loop with a queue and some interpolation to make up for the loss of data. 
    This is very hit and miss so I'm sure there's a proper / better way to do this!

    If you are using standard mode, then the read function should return any partial data, but will report an error out.
    You may want to look at the functions that you call after the TCP read. I think that the enqueue function will NOT enqueue data if there is an error in.
    There is a function you can use to clear TCP timeout errors. You could use this to allow you to enqueue partial data to your consumer loop.
    vi.lib\addons\internet\utils\tcputil.llb\No Time Out Error.vi
    Note that it will be up to your consumer code to identify your 'frames' for proper decoding.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • Error 56 Occurs When Using TCP Read.vi

    TCP Read gives Error 56: The network operation exceeded the user-specified or system time
    limit?
    TCP Read in my application in not reliable. It works sometime, but it fails some other time. I tried to read just 1 byte, and set time out to be 1 min, I still get error code 56. What could cause this problem?

    Most of the time it is due to a poor implementation of TCP-IP and the protocol implementation ontop of that.
    There can be several causes.
    Once the device we talked to could not handle the network traffic, resulting in several TCP-IP retries (part of TCP-IP) and showing the result only after minutes. There was loads of traffic on the network and the device was overloaded with traffic it shouldn't even been listing to. Solution was a router.
    It could just as easily be something else.
    Please post a screenshot or code snippet that shows your implementation and we can give you pointers.
    André
    Regards,
    André
    Using whatever version of LV the customer requires. (LV5.1-LV2012) (www.carya.nl)

  • Error 56 tcp read

    Hi,
    I'm having trouble with the TCP connection. My computer I am working on will be the server, or the listener, which is trying to connect with a linux based computer. I am able to successfully create a connection using TCP listen. When I am trying the TCP read, I am getting an error 56. I understand it is with the timing. I also tried to run the program with an unlimited amount of time (-1), but this did not seem to resolve the issue. I've attached the screen shots of the code. Server_Listen is the connection to initiate the listening, and Server_Read illustrates how my read is implemented.
    Help? :-)
    Thanks,
    Andrea
    Attachments:
    Server_Listen.gif ‏5 KB
    Server_Read.gif ‏4 KB

    More likely than not you are not receiving 20 bytes of data. Your read is expecting to receive 20 bytes. If you don't you will get a timeout error and the whatever data that you did read will be returned. If you set the timeout to -1 you will read forever until 20 bytes are received. It is quite common in network applications to get a timeout when you don't know how much data you will be receiving. You use this timeout to determine if you did receive a block of data. Further processing can determine if you received the complete data or not. In cases where you have a protocol you need to read data according to the defined protocol. A very common and simple protocol would send a 4 byte value indicating the amount of data to follow. In a case like this read 4 bytes, convert it to an integer and use this as the amount of data for the next read.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Error 56 in TCP Read

    Hi,
    I have TCP Read in a loop  expecting data from some Micropchip boards connected to it. The problem I have is the boards do not send data all the time, hence I cannot wire in a specific constant to the number of bytes to read in, in the TCP read block.
    Am I right in saying the only option is to clear the error 56 when it occurs?
    Thanks,
    Harshil

    That should solve the problem.  See this post...
    There is a VI that you can use to clear this error.  look fo rexamples\comm\UDP.llb\no timeout error.vi
    The VI is located in an LLB named UDP, but the function only checks the error code, it has nothing to do with the connection.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • TCP Read w/ #bytes=4 returns wrong data.

    On an initial TCP Read to a just-open connection, I can read any number of bytes, always getting the first n bytes from the arriving data. Except when I try to read 4 bytes! Then I get 4 bytes, but they're the seventh through ninth bytes, not the first four. Haven't found any other number that gives problems - 1,2,3,5,6,7,8,16,40,1020,etc. all work fine. Ideas?

    You may want to try runnig the Data Client and Data Server example VIs which ship with LabVIEW and see if they work on your system. The Client example actually reads in 4 bytes every time. I ran it and it works fine, so if yours exhibits the behavior you've been seeing, then the problem could be with your connection. Otherwise, if the example does work, then it could be somewhere in your code. Let us know what you find.
    J.R. Allen

  • TCP Read blocks remote Port

    HI,
    I want to read a NMEA string(update rate 1 Hz) from a server. The original NMEA(serial, 4800 Baud) is converted by a MOXA to TCP.
    Here is my minimal program, I have normally a "wait until 1000ms" timer inside.
    The problem is that the MOXA closes its port every other minute. I still can read but every one else is blocked.
    Other terminal programs work. The network guy tells me that he sees a lot of traffic coming from my adress and he thinks that at some point the MOXA is confused and closes its ports.
    Is there a possibility that TCP read sends a status or failure string?
    Solved!
    Go to Solution.

    azavarsky wrote:
    HI,
    I want to read a NMEA string(update rate 1 Hz) from a server. The original NMEA(serial, 4800 Baud) is converted by a MOXA to TCP.
    Here is my minimal program, I have normally a "wait until 1000ms" timer inside.
    The problem is that the MOXA closes its port every other minute. I still can read but every one else is blocked.
    Other terminal programs work. The network guy tells me that he sees a lot of traffic coming from my adress and he thinks that at some point the MOXA is confused and closes its ports.
    Is there a possibility that TCP read sends a status or failure string?
    How fast does this device send its strings? Does it simply spew data without any query command having to be send? If so your Moxa may have a problem too, as it may not know what to do with the data if there is no client connected to read it. Also your Moxa converter may have trouble to serve more than one TCP client on the same port anyhow. What should it do if several clients try to access the same port? Send the same message to each? Or send the incoming message randomly to one of them?
    Do you get errors from your TCP Read once Moxa "closes" the port as you say? If so you should terminate your loop on any error except possibly a timeout error and reopen the port in a second outer loop until your program wants to exit. Your loop never stopping on errors will prevent the TCP Close to execute which will keep the socket open and prevent the Moxa from seeing the proper handshaking that the connection has been properly closed by the client, which will likely prevent the Moxa device from being able to accept new connections. Network communication can be tricky and one of the first things you have to learn is proper error handling. Just about any error anywhere in the network connection, except usually a timeout error on read, should be handled by closing the connection and trying to reconnect.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • TCP read error 57

    Hi, everyone:
    In my graduation design,  I need to acquire the data of biscuits from a video and then send it to a VC program. I've achieved the sending process correctly and the program can receive the data. But when I wanted to send a message from the VC program to LabVIEW, the TCP  read error 57 occurred.
    The TCP write VI and the TCP read VI are in different loops, and they use the same refnum. In the picture, the case structure in top while loop is the data acquiring program so I don't show them.
    Can anybody teach me how to correct this program so it can receive data from the VC program? Thanks and forgive my poor English!

    Hi,
    Today i haven't any problem on the connection. The file is not changed. I think the system held some processes those use the tcp connection. I didn't think to watch in the task manager. It is the only explanation that I can pop out. Anyway I put above the program that gave me that problem. Please, check if the application is bad-built and suggest to me an alternative. Thanks
    The block linked over is send-receive packet, opened above. In the first frame the block above send a message on the tcp connection, then it waits 1 second, finally it waits for the answer on the same connection (8 seconds).
    The tcp reading block returns error 57. No other request on the same connection is active. I let the timeout of the block to end every 50 ms, I ignore error 56 (timeout) end I terminate the loop execution if:
    - a message of a least 5 character is received (application protocol specification).
    - the timeout of the receiving block ends (8 seconds)
    - a tcp error different from 56 turns out.

  • TCP Read Error 1

    Hello!
    I would like to create a server - multi clients program. When i want to run that, the second iteration (top while loop, when listen a client) give the Error 1 error in the TCP Read.vi.
    Somebody could help me? 
    (Sorry about my english, it isn't the best)
    Thanks
    Attachments:
    MCP.zip ‏54 KB

    Dear tibtobi!
    Welcome on NI Discussion Forums! 
    In my opinion for such kind of projects it is better to use an already working solution.
    Please allow me to recommend You a woking  Multiple TCP Clients to One Server implementation:
    Managing Multiple Clients from One Server Using TCP/IP in LabVIEW
    There are also some articles about this topic like this:
    Connecting Multiple TCP Clients to One Server in LabVIEW
    There is also a reference library made by NI:
    LabVIEW Simple Messaging Reference Library (STM)
    In my opinion You could save a lot of time by using these already existing resources an implementations.
    Please let me know, if my suggestion helped, or if You have any other questions.
    Best Regards,
    Balazs Nagy

  • Continuous TCP reading from RT system

    Hello everyone!
    Project:
    I have an AVR32 Board which continuously collects data and sends it to a PC. The PC communicates with the AVR via LabVIEW for data processing and e.g. setting the measurement parameters. Up until now I used a RS232 connection and processed the incoming data via the VISA driver. But since the serial connection is so slow I now want to upgrade to TCP/IP.
    Current working state:
    With the serial connection I checked the COM-port buffer every n milliseconds and processed the data in a queue afterwards. So basically my VI checked if the PC received something and processed it right away.
    Problem:
    So I tried to create a similar VI with TCP Read and I thought that I neededed the Immediate mode. I wanted to do this since it's a continuous data stream with a custom protocoll where the package sizes vary. But while wireshark tells me that the data packages arrive, I can't read them in LV.
    Basically I have the same problem as this guy. But sadly he already worked it out without enlightening poor bastards like me . So could you please help me with this?
    I attached my current testing VI.
    Thanks,
    Prunebutt
    Solved!
    Go to Solution.
    Attachments:
    tcp_test.vi ‏12 KB

    Sorry for the doublepost... where's the edit button? o.O
    Ok, I could've figured it out by myself. My problem was that I had to specify how many bytes there where to read. My VI received the packets as soon as I told it to wait for 1 byte to read.
    Thanks for reading anyways.

Maybe you are looking for

  • My develop option in Lightroom 5 will not work. It says I need to renew my membership but I have it for another 9 months. What is the problem

    I went  to see my LR. When I went to work on images and I went to DEVELOP it says I need to renew my membership. That is not possible because I bought the membership in Dec 2014 and it was the 1 year membership. What could be the issue? Please advise

  • Cant change my message memory

    hi i bought nokia 3500 2 dayz back and im having problemz with changing the message memory from phone to my memory card... cuz it only hav 8 mb internal in wich 3 mb z already in use cuz of system files, and plus i recieve many msgz n i dont wana del

  • Special Column names in SQL Server

    Hi, I am trying to use ODI to load data from SQL Server to Oracle. My problem is having special column names in the old SQL Server database. The columns have names such as 9500Column1. I tried enclosing the names with square barckets in the model def

  • DN always forwarding to VMail

    Hello all, I have DN=1000...everytime i call it i go directly to vmail...i tried deleting the phone/DN re-adding...same thing...any ideas? TIA

  • SOAP Exception with proxy client

    Hello gurus!, this time i have a problem consuming a several webservice, the specific operation it's goods receipt for purchase order (transaction MB01) using movement type 101 (Goods receipt for purchase order into warehouse/stores), we generate a r