Synapse - aborting HTTPMethod lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Dibo · 2010-10-08 16:32 Hi, I have THTTPSend created and running in thread. Can I somehow safely abort connection from main thread when THTTSend.HTTPMethod takes too long? This socket have procedure Abort: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     {:You can call this method from OnStatus event for break current data     transfer. (or from another thread.)}    procedure Abort;   But it doesn't work with HTTPMethod('GET', 'http://some.php.sleep.script'); Indy fails too. I tried change Timeout to 1 but doesn't help. Only LNet have no-blocking mode but it can't post xml in body section. Regards ---------------------------------------------------------------------- theo · 2010-10-08 17:03 Freeing the THTTPSend could do the job. ---------------------------------------------------------------------- Dibo · 2010-10-08 18:23 Produces such an error, that even sections of an except and finally can't capture it ---------------------------------------------------------------------- 99Percent · 2010-10-09 02:16 Try putting Application.Processmessages somewhere in your code. ---------------------------------------------------------------------- anna · 2012-07-02 12:12 Quote from: 99Percent on October 09, 2010, 04:16:36 amTry putting Application.Processmessages somewhere in your code. Application.Processmessages and Abort do not help. Look on attachment. Project fail on MessagesProc procedure (110 line in unit1) , because  thread  still tryes to get data from internet even when FREE called. In synapse there is another build-in timer = 9 seconds. ---------------------------------------------------------------------- anna · 2012-07-02 12:17 So in synapse there is no way to disconnect from internet, even if web-server does not response. Synapse-programm will wait for 9 sec. It's really stupid. ---------------------------------------------------------------------- Blestan · 2012-07-02 13:30 Do to use strong words for things that you do not understand 100% ... Abort will not work because your are not in the middle of receiving huge data packets but you are hanging  in a "connect" operation witch timeout is controlled by the os kernel if you run the http request code in a thread the wait is not a problem ... just leave the thread to finish or set a minimal timeout for socket operations ... you can do a "ping"  (even with empty request) prior any other operations just to "know"" if the server is online and depending on time needed to receive the response you can decide how many ms to wait in future operations   or query another server. in one project i used a similar approach - i have a list of servers to choose from so first i run N threads to connect to the N servers ... as soon as a thread connects to server it put the ip in a available list ... then the request code waits just for the first server to be available and start the operations .. on next request if more servers are found by the rest of the threads  a round robin schema is used for load balancing ...