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

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.

I also have this issue.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’