Board index » delphi » Dealing with FTP "hanging"

Dealing with FTP "hanging"

I have an application which uses FTP to upload files to a server.  Every
once in a while something happens either to the net or on the server which
causes the upload to pause.  This appears to the user as if the application
has hung.  What would be a good strategy for dealing with this?  I thought
of using a TTimer to ping the server every 60 seconds or so so that I can
visually show the user that while the upload has paused the server is still
reachable.  Also, am I right to asume that TIdAntiFreeze allows the user to
hit a Cancel button and that event will trigger even though the Put has yet
to complete, so it can be Aborted?

--

Quidquid latine dictum sit, altum videtur.

 

Re:Dealing with FTP "hanging"


Quote
"DRS" <d...@removethis.ihug.com.au> wrote in message news:3d1632e6_1@dnews...

I have an application which uses FTP to upload files to a server.  Every
once in a while something happens either to the net or on the server which
causes the upload to pause.  This appears to the user as if the application
has hung.  What would be a good strategy for dealing with this?  I thought
of using a TTimer to ping the server every 60 seconds or so so that I can
visually show the user that while the upload has paused the server is still
reachable.  Also, am I right to asume that TIdAntiFreeze allows the user to
hit a Cancel button and that event will trigger even though the Put has yet
to complete, so it can be Aborted?

--

Quidquid latine dictum sit, altum videtur.

Re:Dealing with FTP "hanging"


"DRS" <d...@removethis.ihug.com.au> wrote in news:3d1b2209_1@dnews:

Quote
> this?  I thought of using a TTimer to ping the server every 60 seconds or
> so so that I can visually show the user that while the upload has paused
> the server is still reachable.  Also, am I right to asume that

Use a ReadTimeout.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
      "Programming is an art form that fights back"

   Want more Indy stuff? Try the Atozed Indy Portal at
        http://www.atozedsoftware.com/
    * More Demos
    * Articles
    * Commercial Support

Posted by ELKNews 1.0.4-B
Empower your News Reader! http://www.atozedsoftware.com

Re:Dealing with FTP "hanging"


Quote
"Kudzu" <c...@hower.org> wrote in message

news:Xns923B139A44A8Dcpubindy@127.0.0.1...

Quote
> "DRS" <d...@removethis.ihug.com.au> wrote in news:3d1b2209_1@dnews:
> > this?  I thought of using a TTimer to ping the server every 60 seconds
or
> > so so that I can visually show the user that while the upload has paused
> > the server is still reachable.  Also, am I right to asume that

> Use a ReadTimeout.

I don't understand the documentation on that property.  It says,
"ReadTimeout is an Integer property that indicates the number of
milliseconds that the connection should wait for the peer connection to
become readable using the protocol stack."  What does it mean for a peer
connection to become readable?  The connection between the FTP client and
the server has been established, it's just that something has happened so
that the upload has temporarily stopped.

--

Quidquid latine dictum sit, altum videtur.

Re:Dealing with FTP "hanging"


"DRS" <d...@removethis.ihug.com.au> wrote in news:3d1c53c0_1@dnews:

Quote
> I don't understand the documentation on that property.  It says,
> "ReadTimeout is an Integer property that indicates the number of
> milliseconds that the connection should wait for the peer connection to
> become readable using the protocol stack."  What does it mean for a peer
> connection to become readable?  The connection between the FTP client and
> the server has been established, it's just that something has happened so
> that the upload has temporarily stopped.

It means if X milliseconds passes and no data is received, an exception will be
thrown.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
      "Programming is an art form that fights back"

   Want priority commercial Indy support?

   Qualified help fast with Indy Experts Support
   from the experts themselves:

      http://www.atozedsoftware.com/indy/support/

Posted by ELKNews 1.0.4-B
Empower your News Reader! http://www.atozedsoftware.com

Re:Dealing with FTP "hanging"


Quote
"Kudzu" <c...@hower.org> wrote in message

news:Xns923BCD834C7D1cpubindy2@127.0.0.1...

Quote
> "DRS" <d...@removethis.ihug.com.au> wrote in news:3d1c53c0_1@dnews:
> > I don't understand the documentation on that property.  It says,
> > "ReadTimeout is an Integer property that indicates the number of
> > milliseconds that the connection should wait for the peer connection to
> > become readable using the protocol stack."  What does it mean for a peer
> > connection to become readable?  The connection between the FTP client
and
> > the server has been established, it's just that something has happened
so
> > that the upload has temporarily stopped.

> It means if X milliseconds passes and no data is received, an exception
will be
> thrown.

What do you mean by received?  The user is *uploading*.  The *uploads* are
pausing (for whatever reason out there).

--

Quidquid latine dictum sit, altum videtur.

Re:Dealing with FTP "hanging"


"DRS" <d...@removethis.ihug.com.au> wrote in news:3d1c967b_1@dnews:

Quote
> What do you mean by received?  The user is *uploading*.  The *uploads* are
> pausing (for whatever reason out there).

You'd need a writetimeout then, which doesnt exist yet. :)

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
      "Programming is an art form that fights back"

   Want more Indy stuff? Try the Atozed Indy Portal at
        http://www.atozedsoftware.com/
    * More Demos
    * Articles
    * Commercial Support

Posted by ELKNews 1.0.4-B
Empower your News Reader! http://www.atozedsoftware.com

Re:Dealing with FTP "hanging"


Quote
"Kudzu" <c...@hower.org> wrote in message

news:Xns923C7518314DBcpubindy@127.0.0.1...

Quote
> "DRS" <d...@removethis.ihug.com.au> wrote in news:3d1c967b_1@dnews:
> > What do you mean by received?  The user is *uploading*.  The *uploads*
are
> > pausing (for whatever reason out there).

> You'd need a writetimeout then, which doesnt exist yet. :)

Then how do I solve my problem?

--

Quidquid latine dictum sit, altum videtur.

Re:Dealing with FTP "hanging"


"DRS" <d...@removethis.ihug.com.au> wrote in news:3d1dcab7_1@dnews:

Quote
>> You'd need a writetimeout then, which doesnt exist yet. :)

> Then how do I solve my problem?

You could write an intercept or an IOHandler. Theres an article coming in
SDGN magazine that demonstrates this and I also showed on at BorCon and the
upcoming Borland conferences I'll be showing it again.

I'll also post the code on www.atozedsoftware.com, time permitting.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
      "Programming is an art form that fights back"

   Want priority commercial Indy support?

   Qualified help fast with Indy Experts Support
   from the experts themselves:

      http://www.atozedsoftware.com/indy/support/

Posted by ELKNews 1.0.4-B
Empower your News Reader! http://www.atozedsoftware.com

Re:Dealing with FTP "hanging"


Quote
"Kudzu" <c...@hower.org> wrote in message

news:Xns923D6EC135513cpubindy2@127.0.0.1...

[...]

Quote
> I'll also post the code on www.atozedsoftware.com, time permitting.

Please do.

BTW, the link on www.atozedsoftware.com to the Indy portal doesn't work.  I
keep getting 404s.

--

Quidquid latine dictum sit, altum videtur.

Re:Dealing with FTP "hanging"


"DRS" <d...@removethis.ihug.com.au> wrote in news:3d1f65e9_1@dnews:

Quote
> BTW, the link on www.atozedsoftware.com to the Indy portal doesn't work.  I
> keep getting 404s.

Which link specifically?

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
      "Programming is an art form that fights back"

   Want more Indy stuff? Try the Atozed Indy Portal at
        http://www.atozedsoftware.com/
    * More Demos
    * Articles
    * Commercial Support

Posted by ELKNews 1.0.4-B
Empower your News Reader! http://www.atozedsoftware.com

Re:Dealing with FTP "hanging"


Quote
"Kudzu" <c...@hower.org> wrote in message

news:Xns923E62A7D1C11cpubindy@127.0.0.1...

Quote
> "DRS" <d...@removethis.ihug.com.au> wrote in news:3d1f65e9_1@dnews:
> > BTW, the link on www.atozedsoftware.com to the Indy portal doesn't work.
I
> > keep getting 404s.

> Which link specifically?

http://www.atozedsoftware.com/indy/indynews.html

--

Quidquid latine dictum sit, altum videtur.

Re:Dealing with FTP "hanging"


Based on my experience, altough i'm not using the last version of indy ..
the fix is in:

function TIdSimpleServer.Listen: Boolean;
var start:longint;
begin
  //TODO: Add a timeout to this function.
  Result := False;
  if not FListening then begin
    BeginListen;
  end;
  with Binding do begin
    start:=GetTickCount;
    while (FAbortedRequested = False) and (Result = False) do begin
      Result := Readable(AcceptWait);
      if (not result) and (start+30000 < GetTickCount) then //30 seconds
should be more than enough
         begin //break the loop
              result:=true;
              start:=0;
         end;
    end;
    if start = 0 then
       result:=false;
    if Result then begin
      Accept(Handle);
    end;
    GStack.WSCloseSocket(ListenHandle);
    FListenHandle := Id_INVALID_SOCKET;
  end;
end;

As it was in original this loop will every now end then be an endless one so
that's why i've added the timeout .. (funny enough the sources were
commented as todo a timeout)

Regards and good luck,
Cristian

Re:Dealing with FTP "hanging"


Quote
"Cristian Nicola" <n_crist...@hotmail.com> wrote in message

news:3d2054ca_2@dnews...

[..]

Quote
> that's why i've added the timeout .. (funny enough the sources were
> commented as todo a timeout)

Funny, yeah.  I can't possibly be the first person to have run into this
issue.  You'd think having some way to detect whether the net's died or not
during a file transfer would be rather important.

--

Quidquid latine dictum sit, altum videtur.

Re:Dealing with FTP "hanging"


well ... i've run into it ages ago .. fixed it and forgot about it ..
actually i should be ashamed as i never send it as a feed-back possible bug
fix ... but i was thinking to create a write timeout property .. but then
the software was working fine and i got myself busy with other things ..
well :) maybe they will do it now ...
Unfortunatelly i havent been able to narrow it to something like server type
or resources or whatever as it does not seem to have any rule to go into it
.. maybe it is something with unreliable connections (eg route drops and so
on) - but for me this timeout thing sorted out the problem :)
good luck,
Cristian

ps: if by any chance do you know someone who needs a delphi programmer ...
:)

Go to page: [1] [2]

Other Threads