EldoS | Feel safer!

Software components for data protection, secure storage and transfer

TElSimpleFTPSClient and Proxy

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#8028
Posted: 11/04/2008 05:07:06
by Luigi Guarino (Standard support level)
Joined: 11/08/2007
Posts: 8

Hello,
I'm having problem with proxy ftp connection using TElSimpleFTPSClient.

This is how I setup proxy settings:

Code
  ElFTP.ProxySettings.Host := F.ReadString('ProxySettings', 'Host', '');
  ElFTP.ProxySettings.Username := F.ReadString('ProxySettings', 'Username', '');
  ElFTP.ProxySettings.Password := F.ReadString('ProxySettings', 'Password', '');
  ElFTP.ProxySettings.Port := F.ReadInteger('ProxySettings', 'Port', 0);


  x := F.ReadInteger('ProxySettings', 'ProxyType', 0);
  Case X of
    0: ElFTP.ProxySettings.ProxyType := ptNone;
    1: ElFTP.ProxySettings.ProxyType := ptUserSite;
    2: ElFTP.ProxySettings.ProxyType := ptSite;
    3: ElFTP.ProxySettings.ProxyType := ptOpen;
    4: ElFTP.ProxySettings.ProxyType := ptUserPass;
    5: ElFTP.ProxySettings.ProxyType := ptTransparent;
  end;


Actually I read proxy settings from an INI file. For my test I'm using CCProxy software.
I'm able to connect with CCProxy software using AceFTP. I'm only using "username" as autentication on the proxy server.

When I try to connect with my application I get this error:
" Wrong socket state 4 in SetAddress (error code is 96258)"

I'm not sure on what kind of "ProxyType" I should use, but I get this error with all types.
What I'm missing ?

Thanks for any advice.



#8029
Posted: 11/04/2008 05:18:45
by Eugene Mayevski (EldoS Corp.)

Can it be that you have HTTP proxy? If you do, then you should use ElHTTPSClient and pass the FTP URL "ftp://username:password@host/path/name.ext" to ElHTTPSClient component.

FTP component supports only FTP proxies and frankly speaking they are rare nowadays.


Sincerely yours
Eugene Mayevski
#8035
Posted: 11/04/2008 11:06:53
by Luigi Guarino (Standard support level)
Joined: 11/08/2007
Posts: 8

Hi Eugene,
thanks for you fast reply.
Our costumers (one in particular) are using an FTP Proxy. He told me that with FileZilla he is able to use the FTP proxy (this proxy does not require any user/pass).

My proxy software is configured to use only FTP Proxy, so in theory I should be able to connect using only ElSimpleFTPSClient proxy settings.

I need to write some code in order to do that? I'm doing something wrong?

If you need more specific info feel free to ask!

Regards.

#8038
Posted: 11/04/2008 11:28:54
by Eugene Mayevski (EldoS Corp.)

Hmm. Do you have a text log of the successful FTP connection via this proxy that you can show? It will give a hint regarding what type of proxy is used and how it's used.


Sincerely yours
Eugene Mayevski
#8053
Posted: 11/05/2008 03:47:29
by Luigi Guarino (Standard support level)
Joined: 11/08/2007
Posts: 8

I'll try to get this log as soon as possible, thanks.

#8066
Posted: 11/06/2008 04:32:16
by Luigi Guarino (Standard support level)
Joined: 11/08/2007
Posts: 8

Sorry for the long delay.
This is the log of Filezilla with a successful connection to our server using the ftp proxy:
Code
Status: Using proxy gg
Status: Resolving IP-Address for gg
Status: Connecting to 192.168.21.1:21...
Status: Connection established, waiting for welcome message...
Response: 220 FTP-Relay OK. Login with User@Host.and use Passive Mode (passiv)!
Command: USER ftp_temp@ 666.666.666.666
Response: 331-
Response:  220 Microsoft FTP Service
Response: 331 Password required for ftp_temp.
Command: PASS ********
Response: 230 User ftp_temp logged in.
Command: SYST
Response: 215 Windows_NT
Command: FEAT
Response: 500 Command not allowed by RFC959
Status: Connected
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/ftp_temp" is current directory.
Command: TYPE I
Response: 200 Type set to I.
Command: PASV
Response: 227 Entering Passive Mode (192,168,21,1,97,117)
Command: LIST
Response: 125 Data connection already open; Transfer starting.
Response: 226 Transfer complete.
Status: Directory listing successful


The proxy needs only the username (no password needed). If he didn't provide any proxy settings he will get only this in the log:
Code
Status: Connecting to 666.666.666.666:21...
Error: Could not connect to server


Any Idea?

PS: 666.666.666.666 is our FTP Server (I just put some 6 number to mask the real ip for the privacy).

#8070
Posted: 11/06/2008 06:38:47
by Eugene Mayevski (EldoS Corp.)

Hmm. If you set ProxySettings.ProxyType to ptUserSite, you should get the same result. Can you also produce similar log with your code or modified FTPSDemo sample?


Sincerely yours
Eugene Mayevski
#8072
Posted: 11/06/2008 06:58:37
by Luigi Guarino (Standard support level)
Joined: 11/08/2007
Posts: 8

With a modify on the code I should be able to reproduce a log like this.
I'll post it as soon as this costumer can test it.

Regards,

#8078
Posted: 11/06/2008 10:14:02
by Luigi Guarino (Standard support level)
Joined: 11/08/2007
Posts: 8

Ok something is going wrong.
I made a little application to simulate the problem.

Here is the code of the connection:

Code

ElSimpleFTPSClient1.Address := '666.666.666.666';
ElSimpleFTPSClient1.Username := 'FTPUSERNAME';
ElSimpleFTPSClient1.Password := 'FTPPASSWORD';
ElSimpleFTPSClient1.Port := 21;

ElSimpleFTPSClient1.ProxySettings.Host := '192.168.1.153';
ElSimpleFTPSClient1.ProxySettings.Username := 'proxyuser';
ElSimpleFTPSClient1.ProxySettings.Password := 'proxypass';
ElSimpleFTPSClient1.ProxySettings.Port := 21;


LogFTP('***************OPEN');
ElSimpleFTPSClient1.Open;

LogFTP('***************LOGIN');
ElSimpleFTPSClient1.Login;


192.168.1.153 is where the proxy is running.
666.666.666.666 is the fake server ip.

If i run it with ptUserPass I get 'Wrong socket stat 4 in SetAddress (error code is 96258).' I can't log anythings because the program raise this error on ElSimpleFTPSClient1.Open call.


After several test I was able to login into the proxy using this ODD settings:

Code
ElSimpleFTPSClient1.Address := '192.168.1.153';
ElSimpleFTPSClient1.Username := 'proxyuser';
ElSimpleFTPSClient1.Password := 'proxypass';
ElSimpleFTPSClient1.Port := 21;

ElSimpleFTPSClient1.ProxySettings.Host := '192.168.1.153';
ElSimpleFTPSClient1.ProxySettings.Username := 'FTPUSERNAME@666.666.666.666:21';
ElSimpleFTPSClient1.ProxySettings.Password := 'FTPPASSWORD';
ElSimpleFTPSClient1.ProxySettings.Port := 21;


In theory this is totally wrong but still I'm able to connect to the proxy.
Here is the log:
Code
17.12.51 - ***************OPEN
17.12.51 - ***************LOGIN
17.12.51 - <<< 220-CCProxy FTP Service(Unregistered)
220-you need to input userid@site as login name.
220 Example: user anonymous@ftp.netscape.com

17.12.51 - >>> USER FTPUSERNAME@666.666.666.666:21
17.12.52 - <<< 331 Password required for FTPUSERNAME.

17.12.52 - >>> PASS FTPPASSWORD
17.12.52 - <<< 230 User FTPUSERNAME logged in.

17.12.52 - >>> USER proxyuser@192.168.1.153
17.12.52 - <<< 331 Password required for proxyuser@192.168.1.153.

17.12.52 - >>> PASS proxypass
17.12.52 - <<< 530 User proxyuser@192.168.1.153 cannot log in.



After that I get this error: 'Unaccepted server reply (error code is 530).
I used this setting just because AceFTP (a free ftp client that is able to connect using this proxy) do something similar. Here is the AceFTP log:

Code
Connecting to 666.666.666.666 on port 21. Attempt 1 of 3...
Connecting to Proxy firewall at 192.168.1.153 on port 21...
220-CCProxy FTP Service(Unregistered)
220-you need to input userid@site as login name.
220 Example: user anonymous@ftp.netscape.com
USER FTPUSERNAME@666.666.666.666:21
Successfully connected and logged into firewall
331 Password required for FTPUSERNAME.
PASS *****
230 User FTPUSERNAME logged in.
Server Type: Microsoft NT
FEAT
211-FEAT
    SIZE
    MDTM
211 END
PWD
257 "/FTP_root" is current directory.
TYPE A
200 Type set to A.
PASV
227 Entering Passive Mode (192,168,1,153,202,244)
LIST
125 Data connection already open; Transfer starting.
226 Transfer complete.
Transferred 3.009 bytes in 0,16 seconds (18,84 KB/s)



If I don't use the same ip on

ElSimpleFTPSClient1.Address := '192.168.1.153';

and

ElSimpleFTPSClient1.ProxySettings.Host := '192.168.1.153';

I'm unable to get any log since .Open call raise and exception.

Any Idea?

#8085
Posted: 11/06/2008 12:17:38
by Eugene Mayevski (EldoS Corp.)

As I understand it, you should set the following properties (only):

FTP.ProxySettings.Host := '192.168.21.1';
FTP.ProxySettings.Port := 21;
FTP.Address := '666.666.666.666';
FTP.Port := 21;
FTP.Username := 'FTPUSERNAME';
FTP.Password := 'FTPPASSWORD';

And that's all. Don't set ProxySettings.Username and ProxySettings.Password.

Do you need to authenticate on the proxy? From your first log (from FileZilla) it looks like you don't.




Sincerely yours
Eugene Mayevski
Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.

Reply

Statistics

Topic viewed 8857 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!