esc_pos_bluetooth icon indicating copy to clipboard operation
esc_pos_bluetooth copied to clipboard

Connection timeout issue when print continuously

Open sbrsubuvga opened this issue 5 years ago • 8 comments

Connection timeout issue when print continuously.

sbrsubuvga avatar Mar 14 '20 12:03 sbrsubuvga

What's your printer model please?

andrey-ushakov avatar Mar 17 '20 20:03 andrey-ushakov

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. (package:esc_pos_bluetooth/src/printer_bluetooth_manager.dart:138:19) E/flutter (11107): #2 _rootRunUnary (dart:async/zone.dart:1134:38) E/flutter (11107): #3 _CustomZone.runUnary (dart:async/zone.dart:1031:19) E/flutter (11107): #4 _FutureListener.handleValue (dart:async/future_impl.dart:140:18) E/flutter (11107): #5 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45) E/flutter (11107): #6 Future._propagateToListeners (dart:async/future_impl.dart:711:32) E/flutter (11107): #7 Future._complete (dart:async/future_impl.dart:516:7) E/flutter (11107): #8 new Future.delayed. (dart:async/future.dart:313:16) E/flutter (11107): #9 _rootRun (dart:async/zone.dart:1122:38) E/flutter (11107): #10 _CustomZone.run (dart:async/zone.dart:1023:19) E/flutter (11107): #11 _CustomZone.runGuarded (dart:async/zone.dart:925:7) E/flutter (11107): #12 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:965:23) E/flutter (11107): #13 _rootRun (dart:async/zone.dart:1126:13) E/flutter (11107): #14 _CustomZone.run (dart:async/zone.dart:1023:19) E/flutter (11107): #15 _CustomZone.bindCallback. (dart:async/zone.dart:949:23) E/flutter (11107): #16 Timer._createTimer. (dart:async-patch/timer_patch.dart:23:15) E/flutter (11107): #17 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19) E/flutter (11107): #18 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5) E/flutter (11107): #19 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12) E/flutter (11107): D/InputMethodManager(11107): windowDismissed mLockisused = false D/BluetoothBasicPlugin(11107): stateStreamHandler, current action: android.bluetooth.device.action.ACL_DISCONNECTED

kakzaki avatar Mar 23 '20 04:03 kakzaki

Same issue here ... print 2 tickets it's timeout

mjafartp avatar Apr 08 '20 18:04 mjafartp

Have you tried to adjust the queueSleepTimeMs as explained here: https://github.com/andrey-ushakov/esc_pos_bluetooth#troubleshooting ?

andrey-ushakov avatar Apr 08 '20 18:04 andrey-ushakov

we printing 2 separate tickets

mjafartp avatar Apr 08 '20 20:04 mjafartp

i have same issue too.. but when i tracked. the problem maybe in "writeBytes" function, the default step is..

  1. scan and connect to the device in here...
  2. after the device connected, it will print data...
  3. 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

rudythe avatar Jun 12 '20 15:06 rudythe

same error someone managed to solve?

renanzdm avatar Jun 07 '21 18:06 renanzdm