Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
9k views
in Java FTP by (1k points)
Hi,

I'm using edtftpj free version in my java project.

there is an issue we want to sort out.
suppose the following senario :

files are being uploaded to a ftp server (in a separate java thread).then user brutally unplug the lan cable and cutt of network connection...
after few secs user plug the cable again .
Now we need to be able to resume uploading files from point where the network connection went down.

what i did is the following :

i catch exception that is throw when connection is broken ,then i call :
client.resume();


but this doesn't work ,many exceptions are thrown.the exception trace is below.

can someone pint me how to come out right with this issue?

thanks a lot.



DEBUG [FTPControlSocket] 5 Jul 2007 09:25:59.409 : 226 Transfer finished successfully. Data connection closed.
DEBUG [FTPControlSocket] 5 Jul 2007 09:25:59.409 : ---> CWD /staging/Projects/12/View/_Thumbs
DEBUG [FTPControlSocket] 5 Jul 2007 09:25:59.471 : 250-[Ul: 58.61MB] [Dl: 0.00MB] [Speed: UL:45,DL:0 KB/s] [Space: 355042MB]
DEBUG [FTPControlSocket] 5 Jul 2007 09:25:59.471 : 250-[Credits: UnlimitedMB] [Ratio: Unlimited]
java.net.SocketException: Connection reset
   at java.net.SocketInputStream.read(Unknown Source)
   at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source)
   at sun.nio.cs.StreamDecoder$CharsetSD.implRead(Unknown Source)
   at sun.nio.cs.StreamDecoder.read(Unknown Source)
   at java.io.InputStreamReader.read(Unknown Source)
   at java.io.BufferedReader.fill(Unknown Source)
   at java.io.BufferedReader.readLine(Unknown Source)
   at java.io.BufferedReader.readLine(Unknown Source)
   at com.enterprisedt.net.ftp.FTPControlSocket.readReply(FTPControlSocket.java:825)DEBUG [upload.FTPUploadThread] 5 Jul 2007 09:26:08.612 : Error processing thumbnails 'A-group005.jpg'at 

14 Answers

0 votes
by (1k points)
thanks a mil

what is the method to call on FTPClient to disconnect ?

thanks.
0 votes
by (51.6k points)
FTPClient.quit()

- Hans (EnterpriseDT)
0 votes
by (1k points)
sorry ,i'm still having issues with this resume/reconnection problem.

is there another robust approach to monitor when the connection is down and notify my applet so it retry to reconnect & resume ?

the exception thrown approach seems not to be good.

can i for example launch a thread for monitoring connection status & if the thread discovers the connection is down ,it then try to reconnect & resume.

i would appreciate some source code from your part to help on this.

thanks.
0 votes
by (162k points)
The problem is when a connection is down you don't know when it will come up again. All you can do is quit, call sleep, retry connection in a loop.

Instead of quit(), call quitImmediately() (but catch any exceptions) - that will help. Then sleep & try reconnecting.

Categories

...