SendandWaitforResponse doesn't work with TcpConnection

Tags: 

We got everything working over USB, but it is extremely slow (5 seconds per label). We were told that using TCP connection would be faster. So we tried that but can’t even get a response back now. Our ZPL contains ^RFR command to get TID and EPC value. All three print the ZPL, but only the USB connections returns the TID and EPC values. The USB connection works with InitTime = 2000, and MaxTime = 3000. Anything less and I get erratic results. I get no results back for either TCP connection even with InitTime = 5000 and MaxTime = 10000. Also, I am able to connect with the TCP connection with Zebra Utility and send our command and get the correct results back.

So this works:

UsbConnection thePrinterConn = new UsbConnection(usbDriverName);
Response = null;
try
{
// Open the connection - physical connection is established here.
thePrinterConn.Open();

// Send the data to printer as a byte array.
byte[] Return_Value = thePrinterConn.SendAndWaitForResponse(Encoding.UTF8.GetBytes(zplData), InitTime, MaxTime, "V");
Response = Encoding.UTF8.GetString(Return_Value);
}

This does not:

TcpConnection thePrinterConn = new TcpConnection(theIpAddress, TcpConnection.DEFAULT_ZPL_TCP_PORT);
Response = null;
try
{
// Open the connection - physical connection is established here.
thePrinterConn.Open();

// Send the data to printer as a byte array.
byte[] Return_Value = thePrinterConn.SendAndWaitForResponse(Encoding.UTF8.GetBytes(zplData), InitTime, MaxTime, "V");
Response = Encoding.UTF8.GetString(Return_Value);
}

Also Tried this:

Connection thePrinterConn = null;
thePrinterConn = ConnectionBuilder.Build($"TCP:{theIpAddress}:9100");
Response = null;
try
{
// Open the connection - physical connection is established here.
thePrinterConn.Open();

// Send the data to printer as a byte array.
byte[] Return_Value = thePrinterConn.SendAndWaitForResponse(Encoding.UTF8.GetBytes(zplData), InitTime, MaxTime, null);
Response = Encoding.UTF8.GetString(Return_Value);
}