Problem connecting printer on Android Lollipop

// Expert user has replied.
E Enrico Schio 3 years 7 months ago
305 8 0

Hi,
 
I developed an android app that uses bluetooth connection to print receipts through iMZ320 printers, everything works great on Android 4.x, yet on a tablet with Lollipop logs these errors:
 
02-06 17:40:10.790 18479 18498 W System.err: com.zebra.sdk.comm.ConnectionException: Could not connect to device: read failed, socket might closed or timeout, read ret: -1
02-06 17:40:10.790 18479 18498 W System.err:     at com.zebra.sdk.comm.ConnectionA.open(Unknown Source)
02-06 17:40:10.790 18479 18498 W System.err:     at com.zebra.sdk.comm.BluetoothConnection.open(Unknown Source)
02-06 17:40:10.790 18479 18498 W System.err:     at com.labinf.gestioneagenti.oggetti.Printer.connect(Printer.java:51)
02-06 17:40:10.790 18479 18498 W System.err:     at com.labinf.gestioneagenti.threads.PrintAT.doInBackground(PrintAT.java:57)
02-06 17:40:10.790 18479 18498 W System.err:     at com.labinf.gestioneagenti.threads.PrintAT.doInBackground(PrintAT.java:1)
02-06 17:40:10.790 18479 18498 W System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:288)
02-06 17:40:10.790 18479 18498 W System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
02-06 17:40:10.790 18479 18498 W System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
02-06 17:40:10.790 18479 18498 W System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
02-06 17:40:10.790 18479 18498 W System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
02-06 17:40:10.790 18479 18498 W System.err:     at java.lang.Thread.run(Thread.java:818)
02-06 17:40:10.790 18479 18498 W System.err: Caused by: com.zebra.sdk.comm.ConnectionException: read failed, socket might closed or timeout, read ret: -1
02-06 17:40:10.790 18479 18498 W System.err:     at com.zebra.sdk.comm.internal.BluetoothInsecureZebraConnectorImpl.tryPublicApiWay(Unknown Source)
02-06 17:40:10.790 18479 18498 W System.err:     at com.zebra.sdk.comm.internal.BluetoothInsecureZebraConnectorImpl.open(Unknown Source)
02-06 17:40:10.790 18479 18498 W System.err:     ... 11 more
 
These errors show off when:
 
printerConnection = new BluetoothConnectionInsecure(PRINTER_ADDRESS);
        try {
            printerConnection.open();
            Logger.log(zebra_tag, "Connected");
        } catch (ConnectionException e) {
            Logger.log(zebra_tag, "Comm Error! Disconnecting");
            e.printStackTrace();
            // DemoSleeper.sleep(1000);
            disconnect();
        }
 
The PRINTER_ADDRESS is saved this way:
 
1) get the list of devices available
new Thread(new Runnable() {
            public void run() {
                Looper.prepare();
                try {
                    BluetoothDiscoverer.findPrinters(getActivity(),
                            BTscannerDlg.this);
                } catch (ConnectionException e) {
                    // new
                    // UIHelper(BluetoothDiscovery.this).showErrorDialogOnGuiThread(e.getMessage());
                } finally {
                    Looper.myLooper().quit();
                }
            }
        }).start();
2) save the one selected
public void onItemClick(AdapterView parent, View view,
                    int position, long id) {
                DiscoveredPrinterBluetooth p = (DiscoveredPrinterBluetooth) devicesAdp
                        .getItem(position);
                PRINTER_ADDRESS = p.address;
    
If anyone needs more code to understand the problem, just ask for it.
Thank you very much for your help.
 
Enrico

Please Register or Login to post a reply

8 Replies

P Patrick Koo

Digging this thread up as I am having the same issue with a ZQ510 printer on connection.Open(). I am using the LinkOS SDK for Android and things work fine for older Android devices (5.0.1), but get the above error on newer devices (Android 10). On occasion, it also prompts to re-pair when trying to connect.
"com.zebra.sdk.comm.ConnectionException: Could not connect to device: read failed, socket might closed or timeout, read ret: -1"

A Alessandro Caliaro

Hi Enrico. Have you found a solution for this?

M Manuel Caicedo-Rivera

Hi Enrico,

Please, could you add (as attached file) the allcv report, of the printer you are testing, to the following post, also could you give me details of the tablet you are using as well.

If you are not familiar with the allcv report, please, follow the directions on the link below.

https://km.zebra.com/kb/index?page=content&id=SO8613&actp=LIST

Thanks,

MC

E Enrico Schio

Hi Manuel,

adding that permission to the manifest didn't fix the problem. Furthermore the printer still works with others 4.xx devices, but with this one (Lollipop) also the setup client can't pair the printer even if it's scanned, as you can see below, in the screenshot with the error.
Do you have any suggestion?

Thank you very much, again.
ES

M Manuel Caicedo-Rivera

Hi Enrico,

There were some changes that Google introduced with Android 5.0 and upper versions for BT connectivity.

You can try to add these BT permissions to the manifiest. Also, We recommend to use our latest version of our Link-OS SDK. (build v2.11.2800), please, update the latest library to your project.

 
 
 

Please, could you help me with some additional pieces of information to debug your issue better.

1.) Firmware of the iMZ320
2.) Version of the Android Link-OS you are using.
3.) Actual printer language of the printer. Are you using ZPL, CPCL, Line_Print?

Thanks,

MC

E Enrico Schio

Hi Manuel,

first of all, thank you for your help; I use the last versione of link-os (v2.11.2800), the printer language should be CPCL, unfortunately I don't have the printer here and seeing that the connection fails I can't see the log taht shows the current language. For the Firmware of the printer I'll ask for it to our customer, who currently has the printer.

Anyway, I was missing the 3rd permission in manifest, now I'll update the project with this fix and send the app to our customer to test if the problem is fixed.

I'll keep you updated, thank you again.

ES

l leidy russell

It seems like I'm facing this same problem. I'm developing for android (oreo) and I'm using the latest link-os available to connect to a ZD410 printer. I'm able to connect to the printer and print only once. I get "Error: Could not connect to device: read failed, socket might closed or timeout, read ret: -1 /n[Ljava.lang.StackTraceElement;@16830c1"

Y Yang Soon Ee

Hi there, i also have the same problem with the link os sdk in xamarin adnroid, print once and get the error "Error: Could not connect to device: read failed, socket might closed or timeout, read ret: -1 " until i repair. My printer is ZQ521, is there any feedback on this issue?

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