commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mailing User" <>
Subject Re: [NET] No disconnected event? Should poll periodically?
Date Fri, 13 May 2016 19:28:37 GMT
The FTP server had closed the connection due to idling. I expected isAvailable() would return
false in that case, but it returned true. So, my program continued and called listFiles().
It threw an FTPConnectionClosedException or a broken PIPE socket exception.

Sending a NOOP before each command would be inefficient. If I see a famous FTP client like
FileZilla, I can see that it immediately recognises server disconnection and displays the
disconnection message (such as 421 Connection timed out).

I understand that Apache Commons FTP is only for basic protocol, but since many users would
want that feature (immediate recognition for server disconnection), I wish there was a code
snippet for that. I am going to experiment it on my own by extending the FTPClient class.

PS: I am sorry for the wrong tag in the subject.

> Sent: Wednesday, May 11, 2016 at 11:32 PM
> From: sebb <>
> To: "Commons Users List" <>
> Subject: [NET] was: [FTP] No disconnected event? Should poll periodically?
> I assume you are referring to Commons NET here.
> You should probably use isAvailable() instead as that performs more checks.
> However as the method Javadoc says, the only sure way to check if the
> connection is still available is to use it.
> Commons NET does not provide idle connection checking and so there is
> no event for it.
> You will need to implement your own checks, e.g. using sendNoOp()
> every so often.
> Care must be taken to ensure that you only send such probes when the
> connnection is not being used otherwise you might interfere with other
> commands.
> Note that Commons NET is only intended to provide basic access to
> Internet protocols.
> For example it is not intended to replace a full FTP Client, merely to
> provide some building blocks.
> On 11 May 2016 at 15:09, Mailing User <> wrote:
> > I think the connection to a FTP server can be lost. Reasons can be, network disconnection
or client idling.
> >
> > If that happens, can I be notified of the disconnection? I cannot find any "event"
for that. Should I keep polling the state by periodically calling "isConnected()"?
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > For additional commands, e-mail:
> >
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message