Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection timeout issue when print continuously #2

Open
sbrsubuvga opened this issue Mar 14, 2020 · 7 comments
Open

Connection timeout issue when print continuously #2

sbrsubuvga opened this issue Mar 14, 2020 · 7 comments

Comments

@sbrsubuvga
Copy link

Connection timeout issue when print continuously.

@andrey-ushakov
Copy link
Owner

What's your printer model please?

@kakzaki
Copy link

kakzaki commented Mar 23, 2020

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

@mjafartp
Copy link

mjafartp commented Apr 8, 2020

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

@andrey-ushakov
Copy link
Owner

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

@mjafartp
Copy link

mjafartp commented Apr 8, 2020

we printing 2 separate tickets

@rudythe
Copy link

rudythe commented Jun 12, 2020

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

@renanzdm
Copy link

renanzdm commented Jun 7, 2021

same error someone managed to solve?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants