-1

i am using this method to store the file.From computer to server but when i use this i am facing exception. 1. Software caused connection abort: recv failed
2. Software caused connection abort: socket write error
3. org.apache.commons.net.io.CopyStreamException: IOException caught while copying. i don't now how to solve that. please help me

Ravi Jat
  • 11
  • 1
  • 6
  • PLease post more of your code. Do you connect to FTP server before trying to store? – DangeMask Aug 03 '15 at 07:27
  • DBConnection.getFTPConnection().enterLocalPassiveMode(); – Ravi Jat Aug 03 '15 at 07:33
  • yes i connect to ftp server using this query. and when i run to that application this is work properly but when it enter to this point they show the exeption that i told bool = DBConnection.getFTPConnection().storeFile(hostDir, input); – Ravi Jat Aug 03 '15 at 07:35
  • Still not enough. If this is all you got, you are not connected. I don't see anything like `DBConnection.getFTPConnection.open()...` or something similar. – DangeMask Aug 03 '15 at 07:37
  • I have a class of DBConnection in to that the default constructor is using to connect to ftp basic configuration – Ravi Jat Aug 03 '15 at 10:46
  • public DBConnection(){ if(InnertnetConnection.isInternetReachable()){ try { ftpClient.connect(Constants.SERVER_URL, Constants.PORT_NUMBER); ftpClient.setSoTimeout(Constants.connectTimeoutValue); ftpClient.login(Constants.SERVER_USER, Constants.SERVER_PASSWORD); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); ftpClient.enterLocalPassiveMode(); } catch (SocketException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } – Ravi Jat Aug 03 '15 at 10:49
  • and it work properly but some time they show the error .only uploading time it show that exception in downloading its work properly. both place i am useing same DBConnection class to connect the server class – Ravi Jat Aug 03 '15 at 10:56
  • Took me some time to orientate myself. [CopyStreamException](http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/io/CopyStreamException.html) is fired when any IOException occurs during upload. If you catch the CopyStreamException, you can get the original IOException and find out what is the cause. – DangeMask Aug 03 '15 at 11:07
  • I will wait for your Ans. – Ravi Jat Aug 03 '15 at 13:28

1 Answers1

0

Try to catch the exception to get more details:

try {
    bool result = DBConnection.getFTPConnection().storeFile(hostDir, input);
    System.out.println("Upload: " + result);
} catch (CopyStreamException ex) {
    System.out.println("CopyStreamException: " + ex.getMessage());
    System.out.println("Totaly transfered " + ex.getTotalBytesTransferred() + " bytes.");
    System.out.println("Inner IOException: " + ex.getIOException().getMessage());
}

This can help you find the cause of your issue.

DangeMask
  • 531
  • 4
  • 19