In my VCL application, I use TIdHTTP.Get()
to retrieve data from a RESTful web service. In my application, I use the following code:
var
HTTP: TIdHTTP;
ws: WideString;
begin
ws := HTTP.Get('http://www.restfulwebservice.com/' + ObjectId);
end;
My application always runs on a Windows workstation, and I never want to close it. However, from time to time, it reports a nasty exception Connection Reset By Peer. This usually happens after some inactivity.
In such cases, I must close the application and re-open it again, because I have no idea how to handle this exception. I want to properly handle it (within a try..except
block?) to re-open the connection, so there is no need to close and re-run my app.
Are there any practices on how to catch and handle the above mentioned exception? My research showed me some examples of TIdTCPServer
, but not TIdHTTP
.
Im using Delphi Berlin 10.1 Subscription Update 2 on Windows 7 x64.