viewpoint-particle

Author Topic: FTP Failure on XP32  (Read 5783 times)

PaulSamuelson

  • Newbie
  • *
  • Posts: 40
FTP Failure on XP32
« on: September 04, 2013, 07:00:30 am »
I have a FTP Put routine that consistently fails on some computers, and always works on another. The only significant difference I can come up with is it always works on XP64. It also works on Win 2K.

I am sending several thousand small files to a local (FileZilla) FTP server. I have tried changing the data and control send and receive timeouts and it still fails at about the same point. I have another, very similar routine that works/fails the same way.

The initial connection works fine. It fails hundreds or thousands of files into the loop.

The WinNT Extender is version 44084.

The iGet Response when it fails is:
0:200 Type set to I.
200 Port command successful
150 Opening data channel for file transfer.
226 Transfer OK

I would really like to figure out what is wrong to eliminate the dependance on the 64-bit machine.

The C counter is used to only update the progress bar every 10 files, to improve total performance.

Thanks,

Paul Samuelson


hTop=iBegin(0,"","")
hCon=iHostConnect(hTop,FTPServer,@FTP,userid,pswd)
Terminate(hCon==0,"ERROR","Unable to connect to host")
iOptionSet(hCon,"write_buffer_size",100000)
iOptionSet(hCon,"read_buffer_size",100000)

If !iFtpDirChange(hCon,DestPath)
  iFtpDirMake(hCon,DestPath)
  iFtpDirChange(hCon,DestPath)
End If

jpegArray=FileInfoToArray(SourcePath:"*.jpeg",2)
JPEGs = jpegArray[0,0]

If JPEGs>0
  ArraySort(jpegArray,@ASCENDING,0,1)
  c=1
  For yy=1 To JPEGs
    loc_File=jpegArray[yy,0]
    loc_Size=jpegArray[yy,1]
    dest_File=FileRoot(loc_File):".":FileExtension(loc_file)
    If !iFtpPut(hCon,loc_File,dest_File,loc_size,@BINARY) Then Pause("Oops",loc_File:@CRLF:dest_File:@CRLF:iGetResponse())
    If c==10
      If !aStatusbar(1,applet,"Sending JPEG ":yy:" of ":JPEGs:@CRLF:FileRoot(loc_file),JPEGs,yy) Then Exit
      c=0
    End If
    c=c+1
  Next
End If

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: FTP Failure on XP32
« Reply #1 on: September 04, 2013, 09:08:09 am »
I recommend adding code to capture the return value of iFtpPut. If iFtpPut returns 0 or 2 you can call iGetLastError and iGetResponse to get extended error information.

Code: Winbatch
rslt=iFtpPut(hCon,loc_File,dest_File,loc_size,@BINARY)
If rslt==0 || rslt == 2
   errordata = "Source file: ": loc_File:@lf:"Remote file: ":dest_File:@lf:"Last Error: ":iGetLastError():@lf:"Error Description: ": iGetResponse()
   Pause( "iFtpPut rslt =":rslt, errordata  )
EndIf

Also, note that the iFtpDialog function can be used to display progress of an FTP operation.

Deana F.
Technical Support
Wilson WindowWare Inc.

PaulSamuelson

  • Newbie
  • *
  • Posts: 40
Re: FTP Failure on XP32
« Reply #2 on: September 04, 2013, 09:11:03 pm »
I get a last error of 12002. I don't know what that means.

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: FTP Failure on XP32
« Reply #3 on: September 05, 2013, 08:06:59 am »
I get a last error of 12002. I don't know what that means.

See the topic' WinInet Error Codes ' in the WinInet.chm help file.

Quote
12002 ERROR_INTERNET_TIMEOUT The request has timed out.

What happens if you change the iHostConnect service parameter @FTPPASSIVE? conhandle=iHostConnect(tophandle,server,@FTPPASSIVE, userid,pswd)

Also, are you able to FTP the file using Windows built in FTP.exe or any other FTP program? Check the passive transfer settings in that application.

Reference:
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WIL~Extenders/WinInet+iFtpPut~Error~12002~ERROR_INTERNET_TIMEOUT.txt
 http://support.microsoft.com:80/support/kb/articles/q283/6/79.asp
 
Deana F.
Technical Support
Wilson WindowWare Inc.

PaulSamuelson

  • Newbie
  • *
  • Posts: 40
Re: FTP Failure on XP32
« Reply #4 on: September 05, 2013, 04:38:31 pm »
@FTPPASSIVE solved the problem.

I don't know why it worked on the XP64 machine without @FTPPASSIVE, but I'm glad it works.

Thanks,

Paul

PaulSamuelson

  • Newbie
  • *
  • Posts: 40
Re: FTP Failure on XP32
« Reply #5 on: September 05, 2013, 07:30:37 pm »
The mystery might be solved.

Apparently the firewall on the XP32 machines was running out of open ports. By forcing passive ftp, or disabling the firewall, they work correctly.


DAG_P6

  • Full Member
  • ***
  • Posts: 184
  • WinBatch rocks, and so does Wilson WindowWare!
    • WizardWrx
Re: FTP Failure on XP32
« Reply #6 on: September 22, 2013, 02:05:14 pm »
I cannot think of a single instance in which I used anything but passive in production. It's been a long time since I visited the subject, but doesn't active mode require the local host to open a port for listening, which you cannot do while hidden behind a firewall?
David A. Gray
You are more important than any technology.

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: FTP Failure on XP32
« Reply #7 on: September 23, 2013, 07:50:37 am »
I cannot think of a single instance in which I used anything but passive in production. It's been a long time since I visited the subject, but doesn't active mode require the local host to open a port for listening, which you cannot do while hidden behind a firewall?

The FTP mode determines how the data connection is established and who controls the connection, the client or the server.

Active mode: the client sends the server the IP address and port number on which the client will listen. The server initiates the TCP connection.

Passive (PASV) mode: the client sends a PASV command to the server and receives an IP address and port number in return. The client uses these to open the data connection to the server. This is beneficial where the client is behind a firewall and unable to accept incoming TCP connections.
Deana F.
Technical Support
Wilson WindowWare Inc.

td

  • Tech Support
  • *****
  • Posts: 3016
    • WinBatch
Re: FTP Failure on XP32
« Reply #8 on: September 23, 2013, 07:58:53 am »
With active FTP the client is required to open a data port for the server to use.  The problem is that the server dictates the client's port number ( usually but not necessarily N+1, where N is the port used by the client to connect to the servers port 21) and initiates the connection to the clients port.  This means the client must open a range of ports on its firewall that an external host can connect to.  With passive FTP the roles are reversed in that the server sends a port number and the client initiates the data port connect which is acceptable to the firewall.

Unless MSFT has issued a new Windows firewall for XP with some kind of  "critical update" or you are using a third party firewall, passive ftp should go unnoticed on XP because the XP firewall does not filter outgoing traffic.

Running out of port numbers could be explained by the firewall blocking the incoming requests on the server dictated port after each client attempt to initiate an active ftp session.   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

DAG_P6

  • Full Member
  • ***
  • Posts: 184
  • WinBatch rocks, and so does Wilson WindowWare!
    • WizardWrx
Re: FTP Failure on XP32
« Reply #9 on: September 24, 2013, 12:45:40 am »
Thanks to Deana and Tony for the refresher course on active versus passive FTP modes. I hope the OP gained as much from it as I did.
David A. Gray
You are more important than any technology.

kdmoyers

  • Sr. Member
  • ****
  • Posts: 280
Re: FTP Failure on XP32
« Reply #10 on: September 24, 2013, 04:12:10 am »
Thanks to Deana and Tony for the refresher course on active versus passive FTP modes. I hope the OP gained as much from it as I did.
Me too! thanks!
The mind is everything; What you think, you become.