0 Replies Latest reply on Aug 28, 2018 11:06 AM by Felipe Llancachagua

    Error writing to connection: Software caused connection abort: socket write error - java

    Felipe Llancachagua

      Hi,

      Im trying to print a image using java examples code. This is the java code:

       

          private void sendImageToPrint(boolean shouldStoreImage, String storePath) {

              File imageFile = new File(filePathTextField.getText());

              if (imageFile.exists() && imageFile.isFile()) {

                  Connection printerConnection = null;

                  try {

                      printerConnection = connectionPanel.getConnection();

                      printerConnection.open();

                      ZebraImageI image = ZebraImageFactory.getImage(imageFile.getAbsolutePath());

                      if (shouldStoreImage) {

                          ZebraPrinterFactory.getInstance(printerConnection).storeImage(storePath, image, 540, 412);

                      }

                      ZebraPrinterFactory.getInstance(printerConnection).printImage(image, 0, 0, 550, 412, false);

                  } catch (ConnectionException e) {

                      DemoDialog.showErrorDialog(ImagePrintDemo.this, e.getMessage(), "Connection Error!");

                  } catch (ZebraPrinterLanguageUnknownException e) {

                      DemoDialog.showErrorDialog(ImagePrintDemo.this, e.getMessage(), "Connection Error!");

                  } catch (IOException e) {

                      DemoDialog.showErrorDialog(ImagePrintDemo.this, e.getMessage(), "Image Error!");

                  } catch (ZebraIllegalArgumentException e) {

                      DemoDialog.showErrorDialog(ImagePrintDemo.this, e.getMessage(), "Illegal Arguments!");

                  } finally {

                      try {

                          if (printerConnection != null) {

                              printerConnection.close();

                          }

                      } catch (ConnectionException e) {

                      }

                  }

              } else {

                  DemoDialog.showErrorDialog(ImagePrintDemo.this, "\"" + imageFile.getAbsolutePath() + "\"" + " is not a valid path.", "Invalid File Path!");

              }

          }

       

       

      the error occur when is executed the following code:

        ZebraPrinterFactory.getInstance(printerConnection).printImage(image, 0, 0, 550, 412, false);

       

      and show this error:

      Error writing to connection: Software caused connection abort: socket write error

       

      Im using an emulator printer zpl and it works when i send commands fron notepad for instance.

       

      I really appreciate your help.

       

      Felipe.