These are chat archives for IndySockets/Indy

19th
Sep 2017
mezen
@mezen
Sep 19 2017 05:57
For a good understanding with SSL I prefer Network Security with OpenSSL from Viega, Messier & Chandra. It is a little bit old, but the basement hasnt changed
Valmeras
@Valmeras
Sep 19 2017 21:23
I am using TidHttp ->Get(0 to get data from a camera. This is something which is done repeatedly. After few 2 to 3 minutes, I am getting the error message "Connection closed gracefully". What can be the reason? I think that it may be related to a config with TIdHttp. Because if I do the same thing in Javascript with the same camera url, I never get this error message.
Remy Lebeau
@rlebeau
Sep 19 2017 22:23
@Valmeras obviously, the TCP connection is being closed while TIdHTTP is using it. HTTP is stateless, there is no guarantee that the connection will remain open between requests, unless you ask for it. Are you using HTTP 1.0 or HTTP 1.1? Are you using HTTP keep-alives? A browser is likely to ignore such an error, reconnect, and try again. You can do the same with TIdHTTP if you catch the exception, call Disconnect(), and then re-send the same request again.
Valmeras
@Valmeras
Sep 19 2017 22:26
I am using HTTP1.1. How can I activate HTTPKeep-alives?
Remy Lebeau
@rlebeau
Sep 19 2017 22:27
@Valmeras HTTP 1.1 uses keep-alives by default, unless requested otherwise. You can explicitly enable it (especially for HTTP 1.0) by setting TIdHTTP.Request.Connection := 'keep-alive';, but the server decides whether it wants to honor it or not. What is the value of TIdHTTP.Response.KeepAlive when each response is received? What kind of data are you requesting, and what format (TIdHTTP.Response.ContentType) is the server sending it as?
Valmeras
@Valmeras
Sep 19 2017 22:31
I am trying to copy a Jpeg image. Good question for Contentype. I was thinking about the value I need to set. Is image/jpeg right?
I will check for TIdHTTP.Request.Connection
Remy Lebeau
@rlebeau
Sep 19 2017 22:33
@Valmeras you don't set the type when sending a request, the server sets the type when sending the response. Unless you use TIdHTTP.Request.Accept to tell the server what types you are willing to accept. In which case, you could say image/jpeg. But if you know the server already sends JPEGs, then that is just redundant.
Valmeras
@Valmeras
Sep 19 2017 22:35
And by the way, When I try to use TIdHttp->Connect(), it is always telling me that an Host is required. Even if I set the Host the server IP address:port, it does not accept it. What value do I need to set to Host to be able to use Connect()?
Remy Lebeau
@rlebeau
Sep 19 2017 22:36
@Valmeras You are not supposed to call Connect() directly at all in TIdHTTP. Its request methods, like Get(), handle that internally after parsing the URL for connection info.
Valmeras
@Valmeras
Sep 19 2017 22:37
Ok. Thanks