#1 2012-09-10 09:13:30

paulh
Member
Registered: 2012-05-12
Posts: 44

Asynchronous HTTP calls and/or fast timeout

Hi Arnaud, I'm getting closer to deploying my application using your object to json technology and remote client/server access.
When I lose an internet connection, it takes quite some time for a timeout to occur and in the meantime my application is blocked. Ordinarily I don't mind the application being blocked as most calls are getting or posting data and these are generally quick and need to be synchronous to ensure transactional integrity within the app.
I was considering putting in a thread that sends a pingtest to the server every few seconds so I could show an LED indicator as red or green depending on connectivity. Is there a way to get that to return almost immediately if the comms are down but yet keep a reasonable timeout for the normal server calls which can take a bit longer to respond?
If I were to use an Indy component to ping the server would I need to deploy a separate indy web service on a different port on the server or is there a way I can use the mormot server from indy or can that be avoided altogether by overriding the normal timeout for these 'pingtest' calls?
Thanks
Paul

Offline

#2 2012-09-10 10:02:47

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,240
Website

Re: Asynchronous HTTP calls and/or fast timeout

Issue with such a ping test is that the dedicated test server may be online, but the communication with the main HTTP server may be broken...

So your ping may success, and not HTTP communication.
sad

If you use WinINet / WinHTTP connection, there is a known issue about time out, AFAIK.
See http://stackoverflow.com/questions/11583798
A dedicated thread for communication is needed here.

If you use THttpClientSocket direct socket connection (i.e. TSQLite3HttpClientWinSock class as TSQLRestClientURI), you have a TimeOut property (in milliseconds) which can be reduce to avoid application wait...

Offline

Board footer

Powered by FluxBB