KR 403 printer SDK error com.zebra.sdk.comm.ConnectionException: Error writing to connection

M Markandayarushi Pamu 3 years 6 months ago
276 1 0

Hi ,
I am trying to connect to KR 403 printer in Windows 7 32 bit.

I am getting this error when try to write data to connection.

com.zebra.sdk.comm.ConnectionException: Error writing to connection: ZDesigner KR403
at com.zebra.sdk.comm.DriverPrinterConnection.write(Unknown Source)
at com.zebra.sdk.comm.ConnectionA.write(Unknown Source)
at com.zebra.sdk.comm.ConnectionA.sendAndWaitForValidResponse(Unknown Source)
at com.zebra.sdk.printer.SGD.GET(Unknown Source)
at com.zebra.sdk.printer.SGD.GET(Unknown Source)
at com.zebra.sdk.printer.internal.ZebraPrinterFactoryHelper.getApplNameHocusPocus(Unknown Source)
at com.zebra.sdk.printer.internal.ZebraPrinterFactoryHelper.getLanguage(Unknown Source)
at com.zebra.sdk.printer.internal.ZebraPrinterFactoryHelper.getInstance(Unknown Source)
at com.zebra.sdk.printer.internal.ZebraPrinterFactoryHelper.getInstance(Unknown Source)
at com.zebra.sdk.printer.ZebraPrinterFactory.getInstance(Unknown Source)
at PrintTest.main(PrintTest.java:40)

This is my sample code.

Connection connection = null;
try {
  DiscoveredPrinterDriver[] zebraDriverPrinters = UsbDiscoverer.getZebraDriverPrinters();
  String printerName = "";
   int i=0;
   for (DiscoveredPrinterDriver printer : zebraDriverPrinters) {
   if (i==1) {
  printerName = printer.printerName;
  }
  i++;
  System.out.println(printer.printerName);
  }
  System.out.println(printerName);
  connection = new DriverPrinterConnection(printerName);
  connection.open();
  Thread.sleep(3500);
  ZebraPrinter zebraPrinter = ZebraPrinterFactory.getInstance(connection);
   byte[] bytes = IOUtils.toByteArray(new FileInputStream("D:\\test.txt"));
   connection.write(bytes);
  Thread.sleep(3500);
} catch (ConnectionException e) {
  e.printStackTrace();
} catch (InterruptedException e) {
  e.printStackTrace();
} catch (ZebraPrinterLanguageUnknownException e) {
  e.printStackTrace();
} catch (IOException e) {
  e.printStackTrace();
} finally {
   if (connection != null) {
  connection.close();
  }
}

Please Register or Login to post a reply

1 Replies

Y Yanis Dalabiras

Hi < please make sure your driver is set to bidirectional.

You may also want to provide a longer timeToWaitForResponse on the connection object as the KR403 has older USB support.

CONTACT
Can’t find what you’re looking for?