Error connecting to printer ZD620 through bluetooth from Android devices

Hi,

We have built a Xamarin app that can print some labels. We run this app in Android 8.x and use bluetooth connectivity for sending print jobs. Randomly, the connection creation is failing with below exception. I'm not sure what exactly is causing this exception when trying to connect as its very random. Any help in this highly appreciated.

Zebra.Sdk.Comm.ConnectionException: Could not connect to device: read failed, socket might closed or timeout, read ret: -1 ---> Zebra.Sdk.Comm.ConnectionException: read failed, socket might closed or timeout, read ret: -1
--- End of inner exception stack trace ---
at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method) [0x00068] in <42748fcc36b74733af2d9940a8f3cc8e>:0
at Android.Runtime.JNIEnv.CallVoidMethod (System.IntPtr jobject, System.IntPtr jmethod) [0x0000e] in <9a14097a65a445eaa85f6a3a1ade52a3>:0
at Zebra.Sdk.Comm.ConnectionA.Open () [0x0004a] in <61e485c647de4d8d8f6e8c30104504d1>:0
at LinkOS.Plugin.ConnectionImplementation.Open () [0x00001] in <67c3d7a892674a7e8b61d0e4b7d5ff4c>:0
at MACHe.Implementations.Services.Printing.Label.ZebraPrinterConnectionService.ConnectToZebraPrinter (MACHe.Implementations.Services.Printing.Library.Printer printer) [0x0004c] in <9eab3d6112384157b9cb13ddd79cc822>:0
--- End of managed Zebra.Sdk.Comm.ConnectionException stack trace ---
com.zebra.sdk.comm.ConnectionException: Could not connect to device: read failed, socket might closed or timeout, read ret: -1
at com.zebra.sdk.comm.ConnectionA.throwAsConnectionException(Unknown Source:40)
at com.zebra.sdk.comm.ConnectionA.open(Unknown Source:37)
at com.zebra.sdk.comm.BluetoothConnection.open(Unknown Source:3)
Caused by: com.zebra.sdk.comm.ConnectionException: read failed, socket might closed or timeout, read ret: -1
at com.zebra.sdk.comm.internal.BluetoothZebraConnectorImpl.open(Unknown Source:36)
at com.zebra.sdk.comm.ConnectionA.open(Unknown Source:7)
... 1 more

SDK: LinkOs Xamarin SDK 1.2.0

Connection creation Code

var connection = ConnectionBuilder.Current.Build($"BT:{printer.macAddr}");
connection.Open(); // This is where we get Exception

Printer Model: ZD620

Cheers,
Shiyam

Steven Si
Before calling connection

Before calling connection.Open(), make sure the connection closing is not in progress. For example, it takes 5 seconds (by default) to completely close a BT connection. If the BT connect was in the middle of closing, we would get an exception if we called connection.Open(). Make sure the open() and close() are not interleaved, which is a common cause of this type of exceptions randomly.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments