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.Proxy Type := fpcmOpen; // or fpcmHttpProxyWithFtp; // or another one...?
idFTP1.ProxySettings.UserN ame := ""; // no Proxy - UserName and password requed
idFTP1.ProxySettings.Passw ord := ""; // 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])=>CheckC onnected 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:700 0
FTP-SET-TRANSFERTIMEOUT:70 00
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
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.Proxy
idFTP1.ProxySettings.UserN
idFTP1.ProxySettings.Passw
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])=>CheckC
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:700
FTP-SET-TRANSFERTIMEOUT:70
Connecting to FTP ...
LOG:FTPCONNECTSTART // Calling idFTP1.Connect
LOG:PROXY_L:70.***.***.***
LOG:PROXY_F:192.168.***.**
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 !!!!
//////////////////////////
Why it dosnt work?
Alex
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
- 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?
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?
ASKER
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
try sending a idFTP1.Noop every minute and see what happens
regards
ASKER
i cannot use idFTP1.Noop because the Method:
"idFTP1.Connect" is freezing! and after 5 Min => Exception.
"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?
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?
ASKER
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
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);
idFTP1.Connect(true,7000);
ASKER
there are no Connect function with (boolean, Integer) by Indy 10.
to stop it showing up, go to
Tools|Debugger Options..|Language Exceptions|Add and entering "EIdSilentException"
regards