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


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);
          if (printerConnection.isConnected()) {

             printer = ZebraPrinterFactory.getInstance(PrinterLanguage.CPCL, printerConnection);

     } catch (ConnectionException e) {

          Log.e("Connection error " + e.getMessage();

     } finally {




Can you please kindly guide me what is going on and whether we are doing the right way?

Thanks so much in advance.