02-09-2023 12:56 AM
Hello,
there is an error by using TCP/IP write block.
Application is connected with local printer, using IP address, actually, only this PC has connected to the printer.
Communication works normally, i can print, and then, with no reason, error 66 occurs.
(Hex 0x42) The network connection was closed by the peer. If you are using the Open VI Reference function on a remote VI Server connection, verify that the machine is allowed access by selecting Tools>>Options>>VI Server on the server side.
But because there is no other device communicate with this printer, there is no chance that other device took over communication.
Can someone advice how to solve this issue.
Thanks.
Solved! Go to Solution.
02-09-2023 01:03 AM
Hi milan,
@milan87 wrote:
Can someone advice how to solve this issue.
I had a similar problem with a Modbus/TCP device: some devices monitor their TCP communication and when no new messages arive within a given timeout they close the TCP connection. In such cases you can encounter error 66...
Does your printer has such a timeout setting? (Does its manual mention something like that?)
02-09-2023 02:00 AM - edited 02-09-2023 02:13 AM
If it is HTTP traffic the server will by default always close the connection after it responded unless there is a Keep-Alive header field.
Other protocols do similar fhings. Reopening a connection costs time but if the interface is not used for frequent data transmissions that is not very significant. Always closing and reopening the connection is however a lot easier as the client and server don’t have to monitor the socket status to see if the connection may have dropped out and then force a reconnect anyhow.
Basically even if your printer protocol doesn’t say that it will close the connection you have to be prepared for it anyways if you want stable communication. In TCP communication an error doesn’t mean the device exploded and you can’t communicate with it anymore. It simple means that somehow the connection failed, dropped out or was forcefully closed and you should close your end of the connection and attempt a reconnect.
There are only two exceptions to this:
1) error when trying to open a connection, try again or abandon the attempt
2) timeout error when trying to read, try again to read with the same or a different timeout until you have to consider that the server either died, the cable got cut or the world has stopped to exist. Any other error than timeout means the same as an error elsewhere: close the connection and try to open it again!
02-09-2023 02:29 AM
Hi GerdW,
yes, you have right. Printer was set for 300s timeout. Now timeout checking is disabled.
Thanks a lot.