Closed thuutien closed 2 years ago
Could you please give more details, like:
I just tested and no crash happened. I already have an app in production (Android and iOS) using this plugin and I haven’t faced this problem you point.
Try with the example app, I already tested it and I get a properly handled exception error for this specific use case:
Connection timeout after 10 seconds of waiting ErrorCode.EXCEPTION Status.UNKNOWN Cause.NO_CONNECTION
Hi, I'm using the latest ZSDK, android 8.1 API 27. I use the exact same function in the example (zsdk.printZplDataOverTCPIP). Please check my log.
E/flutter (12830): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(EXCEPTION, Connection timeout after 10 seconds of waiting, {errorCode: EXCEPTION, statusInfo: {status: UNKNOWN, cause: NO_CONNECTION}, settings: null, message: Connection timeout after 10 seconds of waiting}, null) E/flutter (12830): #0 ZSDK._onTimeout package:zsdk/zsdk.dart:81 E/flutter (12830): #1 ZSDK._printDataOverTCPIP.<anonymous closure> package:zsdk/zsdk.dart:247 E/flutter (12830): #2 _rootRun (dart:async/zone.dart:1418:47) E/flutter (12830): #3 _CustomZone.run (dart:async/zone.dart:1328:19) E/flutter (12830): #4 Future.timeout.<anonymous closure> (dart:async/future_impl.dart:864:34)
But that's not a crash, a crash is when app abruptly closes due to some app kill or something. That log is the expected behavior of zsdk, it throws an exception with lot of information about the error, it gives you an errorCode, a status, a cause and even a message. You just need to handle that possible exception that could happen from a Future
call.
Check the Line 1371 from the main.dart
in the sample code, there is an example of how to handle that exceptions.
Let me know if this helps you.
thanks! the problem is the app will be frozen when this issue happens. even in your example. when I get printer details on a non-using IP. the app will be frozen after 10-second timeout.
I don't understand what you mean by frozen, all calls are Future
calls so no frozen should happen. I just tested all available zsdk
api calls using example app and app keeps responsive during the time the call lasts which as you say it is 10 seconds.
so I think this is my side issue then. Please close the issue. by the way, it's working great with ZD620 and ZQ620 models. Thank you for creating a superb pub!
Thanks for reporting that compatible models, I will include it in the tested models in the Readme. I'm glad you found the plugin useful. Glad to help. You can give it a Like in the pub page if you haven't yet.
When there is no device using a ip, the zsdk will crash if I try using printzpldata function to send data to that ip.