Forum > Networking and Web Programming
idHTTP (Indy10): hangs
(1/1)
Renat.Su:
I have a separate worker thread that works with the network via idHTTP.
Working with a synchronous sockets, all the timeouts are set but occasionally somtimes the thread hangs forever [at the request stage that is idHTTP.Get]. Only restart helps.
Who solves this problem?
I want to emphasize that the temporary freezing of the thread is not a problem - it is a secondary thread, the problem is that the timeout seems to be infinite.
More nuances: I work with HTTPS via HTTPS proxy. Otherwise works well, if not for the occasional hang. Works under Linux in daemon app
Some peace of code:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- FHTTPClient:=TIdHTTP.Create; FIDSSL := TIdSSLIOHandlerSocketOpenSSL.Create(nil); FHTTPClient.IOHandler:=FIDSSL; FIDSSL.ConnectTimeout:=10000; FIDSSL.ReadTimeout:=16000; FHTTPClient.ReadTimeout:=16000; FHTTPClient.ConnectTimeout:=10000; FHTTPClient.Socket.ReadTimeout:=20000; FHTTPClient.Socket.ConnectTimeout:=10000; ... ... ... Result:=FHTTPClient.Get(AUrl);
Remy Lebeau:
--- Quote from: Renat.Su on March 17, 2019, 08:53:20 am ---Working with a synchronous sockets, all the timeouts are set but occasionally somtimes the thread hangs forever [at the request stage that is idHTTP.Get]. Only restart helps.
Who solves this problem?
--- End quote ---
There is no way to diagnose this without more information. What URL are you accessing? Is the freeze happening when sending the request, or when reading the response? What does the actual HTTP traffic look like? Do you have a reproducible case you can share to verify this?
--- Quote from: Renat.Su on March 17, 2019, 08:53:20 am ---I want to emphasize that the temporary freezing of the thread is not a problem - it is a secondary thread, the problem is that the timeout seems to be infinite.
--- End quote ---
Indy does use infinite timeouts by default, but you are overwriting them, so they should be working.
I will say that in some VERY RARE cases, I have seen Winsock's select() function freeze indefinitely even though data was available and a timeout was used, but that was an OS issue, not a Indy issue. Doubtful that is what you are encountering, but I'm just throwing that out here.
--- Quote from: Renat.Su on March 17, 2019, 08:53:20 am ---More nuances: I work with HTTPS via HTTPS proxy. Otherwise works well, if not for the occasional hang.
--- End quote ---
Are you getting the hang while connected to the proxy? At what stage during the proxy operations does the hang happen?
--- Quote from: Renat.Su on March 17, 2019, 08:53:20 am ---Some peace of code:
--- End quote ---
So, it is not even your code that is freezing, it is someone else's code?
--- Quote from: Renat.Su on March 17, 2019, 08:53:20 am ---
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- FIDSSL.ConnectTimeout:=10000; FIDSSL.ReadTimeout:=16000; ... FHTTPClient.Socket.ReadTimeout:=20000; FHTTPClient.Socket.ConnectTimeout:=10000;
--- End quote ---
All of those assignments are redundant and should be removed. The Socket property points at the SSL object, so the same properties are being set twice. And the inherited Connect() method will overwrite them anyway with values from the client object.
Renat.Su:
Sorry, just noticed the answer
--- Quote from: Remy Lebeau on March 19, 2019, 05:30:08 pm ---There is no way to diagnose this without more information. What URL are you accessing?
--- End quote ---
Various pages of Instagram via HTTPS
--- Quote --- Is the freeze happening when sending the request, or when reading the response?
--- End quote ---
Honestly haven't checked
--- Quote --- What does the actual HTTP traffic look like? Do you have a reproducible case you can share to verify this?
--- End quote ---
This can be a regular web page, and can be a JSON response from the same instagram web site (API end point).
All this works on the Linux web server. The bug appears only if it works through a proxy. This happens with some proxies that apparently sometimes may not respond . If you remove them, the problem ceases to be.
--- Quote ---Indy does use infinite timeouts by default, but you are overwriting them, so they should be working.
--- End quote ---
I so think, so in confusion
--- Quote ---I will say that in some VERY RARE cases, I have seen Winsock's select() function freeze indefinitely even though data was available and a timeout was used, but that was an OS issue, not a Indy issue. Doubtful that is what you are encountering, but I'm just throwing that out here.
--- End quote ---
This usually happens rarely. But since I had to go requests to Instagram every second or every often that such an event eventually occurs, if there are bad proxies and the thread hangs ((
Renat.Su:
--- Quote ---Are you getting the hang while connected to the proxy? At what stage during the proxy operations does the hang happen?
--- End quote ---
Probably a proxy. If no proxy then had no problems
--- Quote ---So, it is not even your code that is freezing, it is someone else's code?
--- End quote ---
Did not quite understand the question. The code under the link is my
--- Quote ---All of those assignments are redundant and should be removed. The Socket property points at the SSL object, so the same properties are being set twice. And the inherited Connect() method will overwrite them anyway with values from the client object.
--- End quote ---
Thanks. For a socket I set up timeouts already then, trying to solve a problem
Renat.Su:
I used a hack, although I did not correct the reason. From another thread I check if the idHTTP client is hung up and if it is frozen send disconnect to it directly from another thread ::)
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- { Check that the idHTTP client is frozen } if (Now-WorkersHandler.TimeoutChecker)>(1/MinsPerDay * 10) then begin Logger.Error('HTTP Client is frozen. Try to disconnect'); WorkersHandler.DisconnectidHTTP; end; And it helps. The idHTTP client comes out of hibernation
Navigation
[0] Message Index