NetTalk Central

Author Topic: Problem with FTP  (Read 7730 times)

John C

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Problem with FTP
« on: March 20, 2012, 05:09:50 AM »
Hopefully this hasn't been posted already.


Two problems have been observed with FTP in NetTalk 6.18 and Clarion version 8.0.8973.  The first is that ChangeDir does not change to a new directory if the server is changed, even after a Quit command.  Here are the steps to reproduce the problem:

1.     Using Clarion, open up FTP.app, the example application that came with NetTalk. (The attached application, which has modifications, can also be used.)
2.     Compile the application.
3.     Start the executable.
4.     Enter in the values, given below, for accessing the HP server. (If using the attached app, click the “Site 1” button.)
5.     Click the “Get Files” button.
6.     In a flash, the “All done” string will appear.
7.     Change all of the parameters to the Microsoft values given below.  (If using the attached app, click the “Site 2” button.)
8.     Click the “Get Files” button.
9.     An error message appears that says “The connection to the FTP Server could not be opened” and the error number is -53.
10.  Exit the program.
11.  Start the program again.
12.  The previous values for Microsoft are still there.
13.  Click the “Get Files” button.
14.  The “All done” string appears.

   It is clear that the problem is in the attempt to access the second site without exiting.  If one gets files and exits, things work just fine.  If multiple server changes are made in the same session, it fails.
   If logging is turned on, the DebugView log shows that, in this case, a connection to Microsoft is made.  However, it is being sent [CWD /ftp1/] instead of [CWD /Products/mediaplayer/] hence the failure.

   FTPServer = ftp.hp.com
   UserName  = anonymous
   Password = anonymous@hotmail.com
   Dir = /ftp1/

    FTPServer = ftp.microsoft.com
   UserName  = anonymous
   Password = anonymous@hotmail.com
   Dir = /Products/mediaplayer/

    The second problem may be an extension of the first.  If one tries to access the servers at timed intervals, in a timer loop, it appears to have trouble closing the first port and eventually the program stops responding.  The message in the log that is repeated multiple times is:

[Net] [1] NetFTPClientControl._CallDone - Done Called for command = quit, _waitingForComplete set back to 0

    Here are the steps to reproduce the problem:

1.     Create an executable from the attached application.
2.     Start the executable.
3.     Change the timer value as needed (100 = 1 second).
4.     Click the “Site 1” button to fill in the values and get things started.
5.     Click the “Get All” button.
6.     After the timer begins, the status message shows up that the first site is done.  Moments later, a Windows error message appears.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11171
    • View Profile
Re: Problem with FTP
« Reply #1 on: March 20, 2012, 07:21:20 AM »
Hi John,

There have been quite a few FTP updates since the 6.18 build- so I recommend grabbing the latest build and re-try the sequence below. Let me know if there are still any issues.

cheers
Bruce

John C

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Problem with FTP
« Reply #2 on: March 20, 2012, 10:49:44 AM »
Installed the latest build and ran through the same scenarios as stated earlier with no joy. Any assistance you could provide (a workaround) would be greatly appreciated.

Thanks  Bruce.

John

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11171
    • View Profile
Re: Problem with FTP
« Reply #3 on: March 21, 2012, 01:21:59 AM »
Hi John,

You didn't end up attaching your app, and there are a couple of example apps called ftp.app, so I might be on the wrong track, but try this and see if it helps;

On the button that
before the call to
ThisFTPControl.ChangeDir (Dir) ! Change Directory
put
ThisFTPControl.lastDirectory = ''

Let me know.

cheers
Bruce

John C

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Problem with FTP
« Reply #4 on: March 21, 2012, 09:54:06 AM »
Hi Bruce,

It is the FTP app for downloading files.  It was found in accessory\capesoft\NetTalk\FTP\FTP Download Directory.

Setting the last directory to blank fixed the problem with changing directories.  Thanks.

The second problem, where it crashes, still exists.  Attached is the app used for testing the second issue.

Thanks for you help.

John C

[attachment deleted by admin]

John C

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Problem with FTP
« Reply #5 on: April 09, 2012, 06:59:07 PM »
Hi Bruce,

I have found the source of the problem where NetTalk fails if a timer is used with the FTP controls.  The solution that worked for me required a change in two procedures in NetSimp.clw.

Every X minutes, I check Y number of FTP sites to see if there is anything to download.  To do this, I set the PROP:TIMER value on the window.  When I start my download, I turn off the timer and turn it back on if the Quit command is successful.  In this case, the Quit command never returned a success or failure that could be trapped because it was stuck in an infinite loop.  Procedure NetFTPClientControl.TakeEvent was calling self.CalcProgress() which, in turn, called self._CallDone after the socket was closed and self._CallDone  called self.CalcProgress().  Here is what I did to stop the recursion:

Change this:

NetFTPClientControl.TakeEvent PROCEDURE

  code
  parent.TakeEvent()
  case event()
  of EVENT:Timer
    self.CalcProgress()
  End
 

To this:

NetFTPClientControl.TakeEvent PROCEDURE

  code
  parent.TakeEvent()
  case event()
  of EVENT:Timer
    if 0{prop:timer} > 100 or 0{prop:timer} = 0
      self.TimerSet = 1
      Self.timerWas = 0{prop:timer}
      0{prop:timer} = 100
    end
    self.CalcProgress()
  End


Change this:

NetFTPClientControl._CallDone Procedure

  code
  self.Log ('NetFTPClientControl._CallDone', 'Done Called for command = ' & lower(clip(self._Command)) & ', _waitingForComplete set back to 0.')
  self.Busy = 0
  self._waitingForComplete = 0        ! March 2007: This indicates to the Control that there is nothing left for the data     connection to do.

  If self.timerSet
    0{prop:timer} = self.TimerWas
    self.timerWas = 0
    self.timerSet = 0
  End

  self.ProgressUpdateNow = 1
  self.CalcProgress()
  self.TransferState = ''
  self.Done()

 

To this:

NetFTPClientControl._CallDone Procedure

  code
  self.Log ('NetFTPClientControl._CallDone', 'Done Called for command = ' & lower(clip(self._Command)) & ', _waitingForComplete set back to 0.')

  self.Busy = 0
  self._waitingForComplete = 0        ! March 2007: This indicates to the Control that there is nothing left for the data connection to do.

  If self.timerSet
    0{prop:timer} = self.TimerWas
    self.timerWas = 0
    self.timerSet = 0
  End

  self.ProgressUpdateNow = 1
  !self.CalcProgress()
  self.TransferState = ''

  self.Done()

 Please let me know if this will cause problems with the other template features.  I uploaded and downloaded files of different sizes using this code and the app didn’t freeze at all.

Thanks for your time and assistance.

JohnC



Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11171
    • View Profile
Re: Problem with FTP
« Reply #6 on: April 09, 2012, 09:33:55 PM »
thanks for the info - you're right, the problem is the potential for unlimited recursion between _calldone and _calcprogress.

I've tweaked it slightly differently here, to avoid any possible side-effects. that's in 6.27 (which should go out today) and 5.49 as well.

thanks again for the follow-up.

cheers
Bruce