ZebraDevs / LinkOS-Xamarin-Samples

Sample code for developing cross-platform applications on Android and iOS using Xamarin. The demos in this repository are stored on separate branches. To navigate to a demo, please click branches.
Other
8 stars 11 forks source link

Create Connection using ConnectionBuilder not working giving error. #9

Closed jitendrajadav closed 6 years ago

jitendrajadav commented 6 years ago

In my Xamarin forms application I am trying to connect Zebra Printer using IPAddress and Port but it couldn't connect getting error like below

My code is like this ;

` IConnection connection = null; try { connection = ConnectionBuilder.Current.Build("192.168.137.10:9100"); connection.Open(); IZebraPrinter printer = ZebraPrinterFactory.Current.GetInstance(connection); if ((!CheckPrinterLanguage(connection)) || (!PreCheckPrinterStatus(printer))) { return; }

            connection.Write(GetBytes(header));
        }
        catch (Exception ex)
        {
            // Connection Exceptions and issues are caught here            
        }

`

Error :

Zebra.Sdk.Comm.ConnectionException: Could not connect to device: failed to connect to /192.168.137.10 (port 9100) after 15000ms ---> Zebra.Sdk.Comm.ConnectionException: failed to connect to /192.168.137.10 (port 9100) after 15000ms --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0 at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method) [0x00068] in <7802aa64ad574c33adca332a3fa9706a>:0 at Android.Runtime.JNIEnv.CallVoidMethod (System.IntPtr jobject, System.IntPtr jmethod) [0x0000e] in <263adecfa58f4c449f1ff56156d886fd>:0 at Zebra.Sdk.Comm.ConnectionA.Open () [0x00044] in C:\Users\jvanhuis\source\repos\xamarin-sdk\Binding Libraries\ZSDK_ANDROIDX\ZSDK_ANDROIDX\obj\Debug\generated\src\Zebra.Sdk.Comm.ConnectionA.cs:613 at LinkOS.Plugin.ConnectionImplementation.Open () [0x00001] in C:\Users\jvanhuis\source\repos\xamarin-sdk\Link_OS_SDK_for_Xamarin_Portable\LinkOS\LinkOS.Plugin.Android\ConnectionImplementation.cs:106 at KegID.Common.ZebraPrinterManager.SendZplPallet (System.String header) [0x00014] in C:\Project\KegID\KegID\KegID\Common\ZebraPrinterManager.cs:300 --- End of managed Zebra.Sdk.Comm.ConnectionException stack trace --- com.zebra.sdk.comm.ConnectionException: Could not connect to device: failed to connect to /192.168.137.10 (port 9100) after 15000ms at com.zebra.sdk.comm.ConnectionA.throwAsConnectionException(Unknown Source) at com.zebra.sdk.comm.ConnectionA.open(Unknown Source) Caused by: com.zebra.sdk.comm.ConnectionException: failed to connect to /192.168.137.10 (port 9100) after 15000ms at com.zebra.sdk.comm.TcpZebraConnectorImpl.open(Unknown Source) ... 1 more }

let me know what is going wrog.

odelgadillo commented 2 years ago

I have the same problem with using LinkOS.Plugin Zebra nugget package

ssizebra commented 2 years ago

Don't use the LinkOS.Plugin. We should be using the Zebra.Printer.SDK v2.15.2634 package, which can be found in the NuGet Package Manager for your Xamarin project.