Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IDHTTP.Get - "Socket Error #11001. Host not found""
#1
Hi,

A confession first: I've never been playing too much with Indy, so my knowledge is limited to simple tasks.

A task is to send a Get request to a web page (actually an ASP.NET AXD HttpHandler) and receive some response back.

As simple code as:

Code:
var
  idHTTP : TIdHTTP;
  response : TStringStream;
begin
  response := TStringStream.Create('');
  idHTTP := TIdHTTP.Create(nil);
  try
    try
      idHTTP.Get('http://mywebsite.com/MyHandler.axd?id=123', response);
      if idHTTP.ResponseCode = 200 then
        //log ok
      else
        //log not ok
      ;
    except on E : Exception do
      //log exception
    end;
  finally
    idHTTP.Free;
    response.Free;
  end;
end;

For most users this works - response is received.

For some users, the following error is returned "Socket Error # 11001. Host not found.". I suspect it has to do with proxy they are using.

What options do I have to let those "socket error" users specify some more parameters and be able to receive response?

-žarko
Reply
#2
Host not found means that the server isnt available or reachable from that client location. If they are using a proxy, then it might be blocking that due to firewall policy, or that a proxy is required and you are not using the proxy. For HTTP most proxies are transparent, but some places still use the very old SOCKS or HTTP proxy in which you have to tell Indy to use them and need the proxy info from the user.
Reply
#3
(01-15-2021, 04:32 PM)kudzu Wrote: For HTTP most proxies are transparent, but some places still use the very old SOCKS or HTTP proxy in which you have to tell Indy to use them and need the proxy info from the user.

So, would it be enough to let them specify values for the IDHTTP's ProxyParams property (TIdProxyConnectionInfo) ?

Or if not, what exactly is meant by "or that a proxy is required and you are not using the proxy"?

p.s.
I asked and they said they are using a proxy - but nothing more (waiting for more info).

Reply
#4
You need to first know what type of proxy they are using. SOCKS and HTTP proxies are handled differently. Amazing that anyone is still using these non transparent proxies in 2021.. but some still are.
Reply
#5
(01-15-2021, 04:45 PM)zarkogajic Wrote: So, would it be enough to let them specify values for the IDHTTP's ProxyParams property (TIdProxyConnectionInfo) ?

If they are using an HTTP proxy, then yes.

But if they are using a SOCKS proxy, then you will have to assign a TIdIOHandlerStack component (for non-HTTPS requests) or TIdSSLIOHandlerSocketBase-derived component like TIdSSLIOHandlerSocketOpenSSL (for HTTPS requests) to the TIdIOHandler.IOHandler property, and then you can assign a TIdSocksInfo component to the TIdHTTP.IOHandler.TransparentProxy property.

This same technique can also be used for HTTP proxies, replacing TIdSocksInfo with TIdConnectThroughHttpProxy (but I would not recommend doing that for TIdHTTP, since it has its own built-in HTTP proxy support).

Reply
#6
Thanks Remy.

Ok, I'm allowing them to specify ProxyPassword, ProxyPort, ProxyServer and ProxyUsername (properties for TIdProxyConnectionInfo). So, we'll see when they come back after trying to make it work...

There's also a boolean property "BasicAuthentication" - what is this one used for?


-žarko
Reply
#7
(01-18-2021, 09:43 AM)zarkogajic Wrote: There's also a boolean property "BasicAuthentication"  - what is this one used for?

When TIdHTTP receives a response from an HTTP proxy/server asking for authentication credentials, the proxy/server specifies the authentication schemes it supports (BASIC, DIGEST, NTLM, etc). TIdHTTP then checks the currently registered classes in any IdAuthentication... units you have in your uses clause, looking for a class to handle a supported authentication scheme. It then fires the OnSelect(Proxy)Authorization and On(Proxy)Authorization events to let you override any decisions TIdHTTP made, if needed, before a new authentication request is sent back to the proxy/server.

When logging in to an HTTP proxy, the ProxyParams.BasicAuthentication property simply tells TIdHTTP whether or not it is allowed to fallback to the BASIC authentication scheme if another scheme is not used.

When logging in to an HTTP server, the Request.BasicAuthentication property does the same thing.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)