FTP problem using tIpClientFTP

FTP problem using tIpClientFTP

Postby Marco Turco » Wed Jan 14, 2015 11:29 am

Hi, I'm using FWH Dec 2014 with the associated xHarbour version (1.2.3 build 20141106).
I always used tIpClientFtp to transfer files but now with a new server I'm unable to do it.
Please note that using a standard ftp client (example CuteFtp) all runs well and also this self contained sample runs with another server (but with a domain name).
I also checked the tIpClientFtp log sequence but I didn't understand the reason of the problem.
Do you think there are some problem using a direct ip instead of a domain name with tIpClientFtp ?

Anyway this is a small self contained sample that show the problem. Any help really appreciated. Thank you in advance.

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()
local nTimeout,lTrace,cFsrv,cFusr,cFpsw,cFile,cUrl,oFtp

nTimeout=6000

lTrace:=.t.
cFsrv:="88.208.208.197"
cFusr:="test"
cFpsw:="password!"
cFile:="testftp.prg"

cFusr:=charrepl("@",@cFusr,"+")
cUrl:="ftp://"+cFusr+":"+cFpsw+"@"+cFsrv

oFtp:=tIPClientFtp():New(cUrl,lTrace)
oFtp:nConnTimeout:=nTimeOut

if .not. oFtp:open()
msginfo("Ftp error "+oFtp:LastErrorMessage())
quit
endif

if .not. oFtp:UploadFile(cFile)
msginfo("ftp error [upload] "+oFtp:LastErrorMessage())
quit
endif
oFtp:Close()
return nil

//----------------------------------------------------------------------------//
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: FTP problem using tIpClientFTP

Postby Enrico Maria Giordano » Wed Jan 14, 2015 1:37 pm

Marco,

I just run your sample and got no error messages. This is ftp.log:

Code: Select all  Expand view
20150114-14:35:25  :INETCONNECT( 88.208.208.197, 21 )
>> 231F2C0 <<

20150114-14:35:25  :INETERRORCODE( 231F2C0 )
>>          0 <<

20150114-14:35:25  :INETRECVLINE( 231F2C0, , 128 )
>> 220 ProFTPD 1.3.4a Server (ProFTPD) [88.208.208.197] <<

20150114-14:35:25  :INETERRORCODE( 231F2C0 )
>>          0 <<

20150114-14:35:25  :INETSENDALL( 231F2C0, 11, USER test )
>>         11 <<

20150114-14:35:26  :INETRECVLINE( 231F2C0, , 128 )
>> 331 Password required for test <<

20150114-14:35:26  :INETERRORCODE( 231F2C0 )
>>          0 <<

20150114-14:35:26  :INETSENDALL( 231F2C0, 16, PASS password! )
>>         16 <<

20150114-14:35:26  :INETRECVLINE( 231F2C0, , 128 )
>> 230 User test logged in <<

20150114-14:35:26  :INETERRORCODE( 231F2C0 )
>>          0 <<

20150114-14:35:26  :INETSENDALL( 231F2C0, 8, TYPE I )
>>          8 <<

20150114-14:35:26  :INETRECVLINE( 231F2C0, , 128 )
>> 200 Type set to I <<

20150114-14:35:26  :INETERRORCODE( 231F2C0 )
>>          0 <<

20150114-14:35:26  :INETSENDALL( 231F2C0, 7, CWD / )
>>          7 <<

20150114-14:35:26  :INETRECVLINE( 231F2C0, , 128 )
>> 250 CWD command successful <<

20150114-14:35:26  :INETERRORCODE( 231F2C0 )
>>          0 <<

20150114-14:35:26  :INETSENDALL( 231F2C0, 6, PASV )
>>          6 <<

20150114-14:35:26  :INETRECVLINE( 231F2C0, , 128 )
>> 227 Entering Passive Mode (88,208,208,197,175,208). <<

20150114-14:35:26  :INETERRORCODE( 231F2C0 )
>>          0 <<

20150114-14:35:26  :INETSENDALL( 231F2C0, 18, STOR testftp.prg )
>>         18 <<

20150114-14:35:47  :INETERRORCODE( 231F318 )
>>          2 <<

20150114-14:35:47  :INETSENDALL( 231F2C0, 660, #include "FiveWin.ch"//----------------------------------------------------------------------------//function Main()local nTimeout,lTrace,cFsrv,cFusr,cFpsw,cFile,cUrl,oFtpnTimeout=6000lTrace:=.t.cFsrv:="88.208.208.197"cFusr:="test"cFpsw:="password!"cFile:="testftp.prg"cFusr:=charrepl("@",@cFusr,"+")cUrl:="ftp://"+cFusr+":"+cFpsw+"@"+cFsrvoFtp:=tIPClientFtp():New(cUrl,lTrace)oFtp:nConnTimeout:=nTimeOutif .not. oFtp:open() msginfo("Ftp error "+oFtp:LastErrorMessage()) quitendifif .not. oFtp:UploadFile(cFile) msginfo("ftp error [upload] "+oFtp:LastErrorMessage()) quitendifoFtp:Close()return nil )
>>        660 <<

20150114-14:35:47  :INETRECVLINE( 231F2C0, , 128 )
>> NIL <<


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8378
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FTP problem using tIpClientFTP

Postby Marco Turco » Wed Jan 14, 2015 6:24 pm

Hi Enrico.
there is a NIL at the end of the log
and if you check with an ftp client that ftp directory you will find it empty, the file has not been trasferred.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: FTP problem using tIpClientFTP

Postby Marco Turco » Thu Jan 15, 2015 6:25 pm

Solved,
the CentOS server with ProFtpD require the PORT MODE ftp access instead of PASSIVE MODE as default and tIpClientFtp seems doesn't support PORT MODE.
I changed the CentoOS config using modprobe ip_conntrack_ftp to activate the ProFtpD passive mode and the problem is now solved.

I think it could be great if the tIpClientFtp could support the FTP PORT MODE that is more safety than PASSIVE MODE.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: FTP problem using tIpClientFTP

Postby Enrico Maria Giordano » Thu Jan 15, 2015 6:58 pm

Marco,

do you mean "ACTIVE MODE"?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8378
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FTP problem using tIpClientFTP

Postby Marco Turco » Thu Jan 15, 2015 9:04 pm

No, I mean PORT MODE, see image from CuteFtp FTP configuration.
Image
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: FTP problem using tIpClientFTP

Postby Enrico Maria Giordano » Thu Jan 15, 2015 9:16 pm

Marco,

I think PORT MODE is not supported by Windows API so we would need of an external DLL... :-(

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8378
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 42 guests