本文介绍了Zebra打印机连接失败“读取失败,套接字可能关闭或超时,读取ret:-1"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

"java.io.IOException:读取失败,套接字可能关闭或超时,读取ret:-1"异常,当我试图通过蓝牙将android设备与Zebra ZD410打印机连接时.

"java.io.IOException: read failed, socket might closed or timeout, read ret: -1" exception appears while i'm trying to connect my android device with Zebra ZD410 printer through bluetooth.

        try {
            mmSocket.connect();
        } catch (IOException e1) {
            android.util.Log.e(TAG, e1.toString());

            try {
                android.util.Log.i(TAG, "Trying fallback...");
                mmSocket =(BluetoothSocket) mmDevice.getClass().getMethod("createRfcommSocket", new Class[] {int.class}).invoke(mmDevice,1);
                mmSocket.connect();
                android.util.Log.i(TAG, "Connected");
            } catch (Exception e2) {
                android.util.Log.e(TAG, "Couldn't establish Bluetooth connection!");
                try {
                    mmSocket.close();
                } catch (IOException e3) {
                    android.util.Log.e(TAG, "unable to close() " + mSocketType + " socket during connection failure", e3);
                }
                connectionFailed();
                return;
            }
        }

我已经尝试了使用后备套接字连接的解决方案,但是没有帮助.此代码与Epson打印机和其他设备兼容,但不适用于zebra ZD410打印机.可能是什么原因?

I already tried solution with fallback socket connection but it didn't helped. This code works well with Epson printer and some other devices, but not with zebra ZD410 printer. What can be a reason?

推荐答案

我收到了Zebra支持的回复.我的Zebra打印机仅支持Bluetooth LE,解决方案是使用具有蓝牙经典功能的打印机.

I received a response from Zebra support. My Zebra printer supports only Bluetooth LE, solution is to use printer with bluetooth classic capabilities.

这篇关于Zebra打印机连接失败“读取失败,套接字可能关闭或超时,读取ret:-1"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 02:41