Link to home
Start Free TrialLog in
Avatar of alex0101
alex0101

asked on

Connect to FTP via Proxy (Error by Connect > GetResponse([220])) ( Indy FTP Client Delphi ) "Sample code!?" HELP!!

hi,

I'm trying to connect to a FTP Server via Proxy Server,
i receive a exception "Connection Closed Gracefully."

Have somebody a sample sourcecode to connect to FTP via a Proxy Server with Indy FTP Module ?
Is my code wrong?

I have trying to connect with TotalCommander, and its works. Why it dosnt work with my code?
(In Total commander i have choosed "HttpProxyWithFtp")
In my code, i have alredy trying another Proxy types.. but it donst help...

I'm trying following:

// Using Indy V10

idFTP1.AutoLogin := True;
idFTP1.Username := "FTPUserName";
idFTP1.Password  := "FTPUserPasword";
idFTP1.Host         := "Target FTP Host IP Address"; // 70.***.***.***

idFTP1.ProxySettings.ProxyType := fpcmOpen; // or fpcmHttpProxyWithFtp; // or another one...?
idFTP1.ProxySettings.UserName := ""; // no Proxy - UserName and password requed
idFTP1.ProxySettings.Password  := ""; // no Proxy - UserName and password requed
idFTP1.ProxySettings.Host          := "ProxyServerIPAddress"; //192.168.***.***
idFTP1.ProxySettings.Port          := 4480; // Proxy Port

idFTP1.Passive := TRUE; // or FALSE?
idFTP1.ConnectTimeOut := 7000;
idFTP1.TransferTimeOut := 7000;

try
  idFTP1.Connect; // => Exception by GetResponse([220])=>CheckConnected function.
  ShowMessage('Connect is OK!');
except
  on E : Exception do
  begin
     ShowMessage(E.Message);
  end;
end;

Have i fogot anything?

Here is a LOG OUT from my Funktion + idFTP,idTCPConnection units.

///////////////// LOG OUT (FROM Connect Function) /////////////////
PROXY-TYPE:Open
PROXY-HOST:192.168.***.***
PROXY-USER:
FTP-HOST:70.***.***.***
FTP-USER:FTPUserName
FTP: PASSIVE
FTP-SET-CONNECTTIMEOUT:7000
FTP-SET-TRANSFERTIMEOUT:7000
Connecting to FTP ...
LOG:FTPCONNECTSTART // Calling idFTP1.Connect
LOG:PROXY_L:70.***.***.***:21  // Parameters in the Connect function
LOG:PROXY_F:192.168.***.***:4480 // Parameters in the Connect function
LOG:USING TLC? => NO
LOG:CALL CONNECT... // inherited Connect;
FTP-STATUS:Connecting to 192.168.***.***.  // idFTP1.OnStatus
FTP-STATUS:Connected.                                 // idFTP1.OnStatus
LOG:CALL RESPONSE...  // Calling GetResponse([220])
LOG:CALL GetInternalResponse...  // Calling GetInternalResponse
LOG:CALL CheckConnected...       // CheckConnected  => after 5 Min. => Exception
FTP-STATUS:Disconnected.      // idFTP1.OnStatus
ERROR!:Connection Closed Gracefully.  // Exception !!!!
///////////////////////////////////////////////////////////////////////// END LOG ///////////////////

Why it dosnt work?

Alex
ASKER CERTIFIED SOLUTION
Avatar of pcsentinel
pcsentinel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pcsentinel
pcsentinel

If i remember correctly you should only get this when running under the IDE

to stop it showing up, go to

Tools|Debugger Options..|Language Exceptions|Add and entering "EIdSilentException"

regards
Sorry to post so many answers, but for more info go here

http://www.swissdelphicenter.ch/en/showarticle.php?id=1

It might be that the FTP server you are connecting to is timing out the connection after the 5 minutes and cutting you off

regards
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of alex0101

ASKER

- I have alredy trying all possible proxyTypes, donst help...
- passive or not, dosnt help (By TotalCommander its working in passive and NOT Passive modus)
- fpcmUserPas = no user password requed by my test proxy-server = (ProxyPlus)
- "ERROR!:Connection Closed Gracefully." is a exception. (Sourcecode is not complete. see real LOG source:)
   try
      idFTP.Connect;
   except
      on E : Exception do
      begin
         Memo1.Lines.Add('ERROR!:' + E.Message);  // LOG OUT:  ERROR!:Connection Closed Gracefully.
      end;
   end;
- its real possible that my Internet-FTP-Server has a timeout of 5 Minutes, but why its freezing on Connect ? I can not call any other function (f.e. idFTP1.Get), only after exception!
- if the ProxyPlus is down, and i using direct connection without Proxy, its works without problems! (No Proxy settings for idFTP set)

Have somebody a sample-code?

Regards,
Alex
 
   
Please read the advise re: connection closed gracefully.

The developers clearly state that this is not an exception, but a notification.

Is the disconnect happening immedialtey after the connect?

If you use a stansard FTP program like SmartFTP with the same settings, what happens?

Q: Is the disconnect happening immedialtey after the connect?
A: No, after 5 Min.

Q: If you use a stansard FTP program like SmartFTP with the same settings, what happens?
A: I using TotalCommander as FTP Client, it work without problems.
It might be that the FTP sight has a 5 minute timeout on no activity and that TotalCommander is sending a keepalive message to the FTP site

try sending a idFTP1.Noop every minute and see what happens

regards
i cannot use idFTP1.Noop because the Method:
"idFTP1.Connect" is freezing!  and after 5 Min => Exception.


But your log file shows succesful connection i.e.

FTP-STATUS:Connecting to 192.168.***.***.  // idFTP1.OnStatus
FTP-STATUS:Connected.                                 // idFTP1.OnStatus                      <<<<<<<<<<<<<<HERE
LOG:CALL RESPONSE...  // Calling GetResponse([220])
LOG:CALL GetInternalResponse...  // Calling GetInternalResponse
LOG:CALL CheckConnected...       // CheckConnected  => after 5 Min. => Exception

What are you doing immedialty after connect?
succesful connection to LAN IP : 192.168.*.* (Proxy-Server)
Generated from event : idFTP1.OnStatus,  
but the function "connect" still working!

// OnStatus LOG by executing idFTP1.Connect:
1. FTP-STATUS:Connecting to 192.168.***.***.  //  idFTP1.OnStatus
2. FTP-STATUS:Connected.                                 // idFTP1.OnStatus    
3. FTP-STATUS:Disconnected.                             // idFTP1.OnStatus
4. ..... here "idFTP1.Connect" still working .........
5. THAN EXEPTION FROM "idFTP1.Connect"

The functions :
  - GetResponse([220])
       - GetInternalResponse
          - CheckConnected
are in the "idFTP1.Connect". Exeption comming from CheckConnected.

Q: What are you doing immedialty after connect?
A: Nothing, because i receive a exeption from "idFTP1.Connect"

Alex
try

idFTP1.Connect(true,7000);
there are no Connect function with (boolean, Integer) by Indy 10.