Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.7k views
in Java FTP by (160 points)
i use edtftpj 2.0.4 to send small files from many machines to one ftp server ... i keep on finding not-sending machine everyday with different error occured such as:

note: errors below happened when the machine is retrying to send:


1.
<Wed Mar 30 23:44:33 SGT 2011>Connection reset
<Wed Mar 30 23:44:33 SGT 2011>Connection reset by peer: socket write error

2.
<Wed Mar 30 23:35:58 GMT+07:00 2011>Control channel unexpectedly closed ('' read so far)

3.
<Thu Mar 31 00:07:18 GMT+07:00 2011>Software caused connection abort: recv failed
<Thu Mar 31 00:07:18 GMT+07:00 2011>Software caused connection abort: socket write error

4.
<Wed Mar 30 22:54:05 GMT+07:00 2011>Connection timed out.

[b]note: error below happened right before the file is about to send (connected successfully)[/b]

5. <Wed Mar 30 23:15:56 GMT+07:00 2011>Permission denied *the previous day, the machine [b]successfully [/b]sent the files as it's controlled by a scheduler so there is no way that the username or password changed*


what am i supposed to do? could you please tell me what is going on for each error listed above? thank you very much and i really appreciate your help..

Regards,
Novi

this is the code of preparing and sending process:


ftpConnect ftpCli = null;

                if(subDir.length() == 0) {
                    ftpCli = new ftpConnect(ipAddr, username, password); 
                } else {
                    ftpCli = new ftpConnect(ipAddr, username, password, subDir); 
                }
                if(!ftpCli.ftp.connected()) {        
                    ftpCli.createTimeredConnect(ipAddr, username, password, subDir);[i] --> a call to timeredConnect method as i wrote below[/i]
                }


for (int ctr = 0;ctr<files;ctr++) {
                        String fileToSend = pathsumberfilenameToSend+"\\"+contentsfilenameToSend[ctr].getName();
                        String filenameToSend = contentsfilenameToSend[ctr].getName();

                        String fileToSendZIP = pathsumberfilenameToSend+"\\"+contentsfilenameToSend[ctr].getName()+".zip";
                        String filenameToSendZIP = contentsfilenameToSend[ctr].getName()+".zip";
                        try {
                            f.zipFile(fileToSend, fileToSendZIP);
                        }
                        catch(Exception e) {
                            FileIO.Writelog(e.getLocalizedMessage());
                        }

                        ftpCli.setLocalRemoteFile(fileToSendZIP, filenameToSendZIP);
                        boolean b;
                        if(!ftpCli.ftp.connected()) {
                            ftpCli.ftp.connect();
                        }
                        
                        b = ftpCli.doUpload();
                        Long SizeRemote = ftpCli.ftp.size(filenameToSendZIP);
                        Long SizeLocal = f.getFileSize(fileToSendZIP);//Upload

                        if((SizeRemote < SizeLocal) || (!b)) {                                           //kalo gagal upload, coba sampe 5 kali
                            ftpCli.ftp.login(username, password);

                            if(subDir.length() != 0) {
                                ftpCli.ftp.chdir(subDir);
                            }

                            ftpCli.createTimeredUpload(fileToSendZIP, filenameToSendZIP);[i] --> a call to TimeredUpload class as i wrote below[/i]
                            if(ftpCli.TU.success) {                                                       
                                f.deleteFile(fileToSend);
                                f.deleteFile(fileToSendZIP);
                            }
                        }

                        if(b) {
                            f.deleteFile(fileToSend);
                            f.deleteFile(fileToSendZIP);
                        }
                    }  ftpCli.ftp.quit();

[i][b]this is the code of doUpl[/i]oad[/b]

public boolean doUpload(){ 
        try {
            if(ftp.exists(remotefile)){
                FileIO.Writelog("File "+remotefile+" has already existed");
     

3 Answers

0 votes
by (51.6k points)
The short answer is that you need to write your code so that it's robust and can recover from errors at any point. This includes reconnecting when you're disconnected and resuming interrupted transfers.

Network comms are inherently unpredictable and can (and do) fail at any time. It's impossible to eliminate failures so the best you can do is to make sure you can recover from them.

All of the errors you mentioned are normal comms errors. The first four are caused by unstable connections. The last one may be due to another process having a lock on the file.

- Hans (EnterpriseDT)
0 votes
by (160 points)
i have put 5-time retry in timeredConnect and timeredUpload function and i'm afraid if i set it more than 5 times it would cause the netcomms traffic busier as i put this program in transactional machines which rely on netcomms traffic so much. could you please tell me in what part should i put additional code so that it would me more robust? thank you.
0 votes
by (51.6k points)
You initial message was pretty broad so my reply was generic. Perhaps it's better if we focus on a particular error. Could you please enable logging at the DEBUG level, rerun your code until it fails with one of the errors and then post the appropriate part of the log? Chances are that the way that you deal with this error will also cover many of the other cases.

- Hans (EnterpriseDT)

Categories

...