Get a "read failed, socket might close or timeout ...." error

M Moe Htwe 2 years 10 months ago
112 1 0

Hi,

We are using Zebra printer ZQ520 to print a receipt from our android application. For some users, when they tried to print after printer went into sleep mode for some time, they kept getting "Cannot connect to device, read failed..." error until they finally switched off the printer and switched it on again to have a success print.
For .eg. one user - he was successfully able to print  a receipt for first two times. Then printer went into sleep for about 2.5 hours and tried to print it again. But was not able to because he kept getting "Cannot connect to device, read failed..." error. Then he switched it off and switched it on again to print it successfully. Please see below for codes that we use to print.

public void print() throws ConnectionException {
     try {
          Connection printerConnection = new BluetoothConnection(bluetoothAddress);          printerConnection.open();          if (printerConnection.isConnected()) {
             printer = ZebraPrinterFactory.getInstance(PrinterLanguage.CPCL, printerConnection);             printerConnection.write(getData(noOfCopies));          }
     } catch (ConnectionException e) {
          Log.e("Connection error " + e.getMessage();
     } finally {
          printerConnection.close();
     }
    }

Can you please kindly guide me what is going on and whether we are doing the right way?
Thanks so much in advance.

Please register or login to post a reply

1 Replies

B Benjamin Kalb

I also have this issue.

CONTACT
Can’t find what you’re looking for?