I have a function (with Host = 'https://api.ipify.org/'
):
TRespEx=record
Resp:IHttpResponse;
EError:String
end;
function CheckIp(UseProxy: Boolean = True; Host: String = ipcheck;
ProxyHost: String = '127.0.0.1'; ProxyPort: Integer = 9090): TRespEx;
var
Cli: THttpClient;
begin
Cli := THTTPClient.Create;
Cli.SecureProtocols := [THTTPSecureProtocol.SSL2, THTTPSecureProtocol.SSL3,
THTTPSecureProtocol.TLS1, THTTPSecureProtocol.TLS11,
THTTPSecureProtocol.TLS12, THTTPSecureProtocol.TLS13];
try
try
if UseProxy = True then Cli.ProxySettings.Create(ProxyHost, ProxyPort);
Cli.SetUserAgent(PUserAgent);
Result.Resp := Cli.Get(Host);
except
on E: Exception do
Result.EError := E.Message;
end;
finally
Cli.Free;
end;
end;
It worked well wthout proxy(False), but a few days ago it broke down. The exception (E.Message
) returns an error:
Error sending data: (12002) The operation time out
I do nothing, I did not change any code. And the function still works, but only with proxy params(True). I know, you say that I blocked the Host, but it still works fine in a browser.
PUserAgent='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0'. I just copied it from my browser user agent.
I turned off the antivirus and firewall, but the result is the same.
Any ideas? I don't understand what the problem is.