esc_pos_bluetooth
esc_pos_bluetooth copied to clipboard
Connection timeout issue when print continuously
Connection timeout issue when print continuously.
What's your printer model please?
Same here
D/BluetoothAdapter(11107): cancelDiscovery
D/BluetoothAdapter(11107): cancelDiscovery = true
D/BluetoothUtils(11107): isSocketAllowedBySecurityPolicy start : device null
W/BluetoothAdapter(11107): getBluetoothService() called with no BluetoothManagerCallback
D/BluetoothSocket(11107): connect(), SocketState: INIT, mPfd: {ParcelFileDescriptor: FileDescriptor[84]}
D/BluetoothBasicPlugin(11107): stateStreamHandler, current action: android.bluetooth.device.action.ACL_CONNECTED
E/DeviceConnFactoryManager(11107): wait read
D/BluetoothSocket(11107): close() in, this: android.bluetooth.BluetoothSocket@2ec8b13, channel: 1, state: CONNECTED
D/BluetoothSocket(11107): close() this: android.bluetooth.BluetoothSocket@2ec8b13, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@34c93150, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@3a908f49mSocket: android.net.LocalSocket@16ab704e impl:android.net.LocalSocketImpl@d8ac56f fd:FileDescriptor[84]
D/BluetoothSocket(11107): Closing mSocket: android.net.LocalSocket@16ab704e impl:android.net.LocalSocketImpl@d8ac56f fd:FileDescriptor[84]
W/System.err(11107): java.io.IOException: bt socket closed, read return: -1
W/System.err(11107): at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:647)
W/System.err(11107): at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:96)
W/System.err(11107): at java.io.InputStream.read(InputStream.java:162)
W/System.err(11107): at com.gprinter.io.BluetoothPort.readData(BluetoothPort.java:130)
W/System.err(11107): at com.tablemi.flutter_bluetooth_basic.DeviceConnFactoryManager.readDataImmediately(DeviceConnFactoryManager.java:418)
W/System.err(11107): at com.tablemi.flutter_bluetooth_basic.DeviceConnFactoryManager$PrinterReader.run(DeviceConnFactoryManager.java:498)
E/BluetoothPort(11107): connection device is lost
E/DeviceConnFactoryManager(11107): read 0
D/BluetoothSocket(11107): close() in, this: android.bluetooth.BluetoothSocket@2ec8b13, channel: 1, state: CLOSED
D/BluetoothSocket(11107): close() in, this: android.bluetooth.BluetoothSocket@2ec8b13, channel: 1, state: CLOSED
E/flutter (11107): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Bad state: Future already completed
E/flutter (11107): #0 _AsyncCompleter.complete (dart:async/future_impl.dart:41:31)
E/flutter (11107): #1 PrinterBluetoothManager.writeBytes.
Same issue here ... print 2 tickets it's timeout
Have you tried to adjust the queueSleepTimeMs as explained here:
https://github.com/andrey-ushakov/esc_pos_bluetooth#troubleshooting
?
we printing 2 separate tickets
i have same issue too.. but when i tracked. the problem maybe in "writeBytes" function, the default step is..
- scan and connect to the device in here...
- after the device connected, it will print data...
- the problem maybe here... after print data, it will delay about 3sec. n disconnect the device...
if u want to print again, the step will restart again... so when the device on progress to disconnect, n new connection is coming, it will time out...
can u make the state. connect to device, disconnect to device, n status "isConnected" so we can access that ???
so if we can manage, to reconnect to device or want time connect until, we want to disconnect the device
same error someone managed to solve?