You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ftpserver-users@mina.apache.org by David Latorre <dv...@gmail.com> on 2010/03/01 11:08:41 UTC

Re: Avoid onuploadend being called after connection lost

Hello Vinicius,

You have to explicitly check the "reply" variable in your
onUploadEnd()/afterCommand() method. This variable  should contain the
last reply of the 'upload'(STOR, STOU...) command which, I guess, will
be >= 400 in case of any IO error.




2010/2/25 Vinicius Carvalho <vi...@sambatech.com.br>:
> Hello there! We are facing some problems with our server. If the remote
> client process dies, the onuploadend method is invoked, and the transfered
> file is not complete. Is it possible to avoid this? Shouldn't a sudden
> disconnection be treated as error?
>
> Regards
>

Re: Avoid onuploadend being called after connection lost

Posted by Niklas Gustavsson <ni...@protocol7.com>.
On Tue, Mar 2, 2010 at 2:20 PM, Vinicius Carvalho
<vi...@sambatech.com.br> wrote:
> Hello there! Unfortunately this approach did not solve our problem. On a
> connection error, we still get a 226 - Transfer Complete code. So no matter
> if the file is complete or not, we keep getting "success" status.

In some cases in TCP/IP, the server can not detect a dropped connected
from a closed. Thus, there will be cases where FtpServer will think
the client is done transferring the file, and it will therefore send a
success reply back. It that's the case for you, you need some other
method to determine that a transfer is complete. A common way is for
the client to upload using a temporary file name (or in a different
directory) and then, after successful upload, move the file into the
final name.

/niklas

Re: Avoid onuploadend being called after connection lost

Posted by Vinicius Carvalho <vi...@sambatech.com.br>.
Hello there! Unfortunately this approach did not solve our problem. On a
connection error, we still get a 226 - Transfer Complete code. So no matter
if the file is complete or not, we keep getting "success" status.

We are still looking for alternatives. Thanks all for the help

On Tue, Mar 2, 2010 at 9:44 AM, Niklas Gustavsson <ni...@protocol7.com>wrote:

> On Tue, Mar 2, 2010 at 1:00 PM, Vinicius Carvalho
> <vi...@sambatech.com.br> wrote:
> > I'm using 1.0.3. Ok tks. I'll give it a try. Since onuploadend does not
> have
> > this argument I wasn't able to figure out. But since its called before
> > onuploadend, I guess I could stack the value on a ThreadLocal to be
> > retrieved later.
>
> Even simpler is to use afterCommand() directly. onUploadEnd() is a
> simplified callback, but you can always use before/afterCommand()
> instead.
>
> /niklas
>

Re: Avoid onuploadend being called after connection lost

Posted by Niklas Gustavsson <ni...@protocol7.com>.
On Tue, Mar 2, 2010 at 1:00 PM, Vinicius Carvalho
<vi...@sambatech.com.br> wrote:
> I'm using 1.0.3. Ok tks. I'll give it a try. Since onuploadend does not have
> this argument I wasn't able to figure out. But since its called before
> onuploadend, I guess I could stack the value on a ThreadLocal to be
> retrieved later.

Even simpler is to use afterCommand() directly. onUploadEnd() is a
simplified callback, but you can always use before/afterCommand()
instead.

/niklas

Re: Avoid onuploadend being called after connection lost

Posted by Vinicius Carvalho <vi...@sambatech.com.br>.
I'm using 1.0.3. Ok tks. I'll give it a try. Since onuploadend does not have
this argument I wasn't able to figure out. But since its called before
onuploadend, I guess I could stack the value on a ThreadLocal to be
retrieved later.

Regards

On Tue, Mar 2, 2010 at 7:27 AM, David Latorre <dv...@gmail.com> wrote:

> What version of FTPServer are you using?  'FtpReply' should be the
> last parameter in the afterCommand() method for an FTPLet.
>
>
> 2010/3/1 Vinicius Carvalho <vi...@sambatech.com.br>:
> > Hello David. I found that this variable is present on IOFTPSession, but I
> > can not access it. How can I get its value?
> >
> > Regards
> >
> > On Mon, Mar 1, 2010 at 7:08 AM, David Latorre <dv...@gmail.com> wrote:
> >
> >> Hello Vinicius,
> >>
> >> You have to explicitly check the "reply" variable in your
> >> onUploadEnd()/afterCommand() method. This variable  should contain the
> >> last reply of the 'upload'(STOR, STOU...) command which, I guess, will
> >> be >= 400 in case of any IO error.
> >>
> >>
> >>
> >>
> >> 2010/2/25 Vinicius Carvalho <vi...@sambatech.com.br>:
> >> > Hello there! We are facing some problems with our server. If the
> remote
> >> > client process dies, the onuploadend method is invoked, and the
> >> transfered
> >> > file is not complete. Is it possible to avoid this? Shouldn't a sudden
> >> > disconnection be treated as error?
> >> >
> >> > Regards
> >> >
> >>
> >
>

Re: Avoid onuploadend being called after connection lost

Posted by David Latorre <dv...@gmail.com>.
What version of FTPServer are you using?  'FtpReply' should be the
last parameter in the afterCommand() method for an FTPLet.


2010/3/1 Vinicius Carvalho <vi...@sambatech.com.br>:
> Hello David. I found that this variable is present on IOFTPSession, but I
> can not access it. How can I get its value?
>
> Regards
>
> On Mon, Mar 1, 2010 at 7:08 AM, David Latorre <dv...@gmail.com> wrote:
>
>> Hello Vinicius,
>>
>> You have to explicitly check the "reply" variable in your
>> onUploadEnd()/afterCommand() method. This variable  should contain the
>> last reply of the 'upload'(STOR, STOU...) command which, I guess, will
>> be >= 400 in case of any IO error.
>>
>>
>>
>>
>> 2010/2/25 Vinicius Carvalho <vi...@sambatech.com.br>:
>> > Hello there! We are facing some problems with our server. If the remote
>> > client process dies, the onuploadend method is invoked, and the
>> transfered
>> > file is not complete. Is it possible to avoid this? Shouldn't a sudden
>> > disconnection be treated as error?
>> >
>> > Regards
>> >
>>
>

Re: Avoid onuploadend being called after connection lost

Posted by Vinicius Carvalho <vi...@sambatech.com.br>.
Hello David. I found that this variable is present on IOFTPSession, but I
can not access it. How can I get its value?

Regards

On Mon, Mar 1, 2010 at 7:08 AM, David Latorre <dv...@gmail.com> wrote:

> Hello Vinicius,
>
> You have to explicitly check the "reply" variable in your
> onUploadEnd()/afterCommand() method. This variable  should contain the
> last reply of the 'upload'(STOR, STOU...) command which, I guess, will
> be >= 400 in case of any IO error.
>
>
>
>
> 2010/2/25 Vinicius Carvalho <vi...@sambatech.com.br>:
> > Hello there! We are facing some problems with our server. If the remote
> > client process dies, the onuploadend method is invoked, and the
> transfered
> > file is not complete. Is it possible to avoid this? Shouldn't a sudden
> > disconnection be treated as error?
> >
> > Regards
> >
>