Recent

Author Topic: Indy 10 socket error 11001 Host not found  (Read 1334 times)

teriyaki

  • New Member
  • *
  • Posts: 28
Indy 10 socket error 11001 Host not found
« on: October 20, 2021, 05:24:11 am »
I install Indy10 and try to get the content of url using indy idhttp

Code: Pascal  [Select][+][-]
  1. var
  2.   get_url: string;
  3.   resp: TMemoryStream;
  4. begin
  5.   get_url := 'http://www.yahoo.com';//edit2.Text;
  6.   resp := TMemoryStream.Create;
  7.   try
  8.     IdHTTP1.Get(get_url+'v', resp);
  9.     resp.Position := 0; // <-- add this!!
  10.     memo1.Lines.LoadFromStream(resp);
  11.   finally
  12.     resp.Free;
  13.   end;

but it always reports error

socket error 11001 Host not found

I even enable the inbound/outbound right of my app in windows defender firewall.

but the error has not change


your comment welcome

engkin

  • Hero Member
  • *****
  • Posts: 2979
Re: Indy 10 socket error 11001 Host not found
« Reply #1 on: October 20, 2021, 08:00:32 am »
get_url+'v'?

dsiders

  • Hero Member
  • *****
  • Posts: 540
Re: Indy 10 socket error 11001 Host not found
« Reply #2 on: October 20, 2021, 03:43:47 pm »
Lazarus 2.0.12, 2.2.0-RC2, 2.3.0 (Git) / FPC 3.2.0, 3.2.2 / x86-win64 / Windows 8.1

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1021
    • Lebeau Software
Re: Indy 10 socket error 11001 Host not found
« Reply #3 on: October 20, 2021, 08:20:15 pm »
Code: Pascal  [Select][+][-]
  1. IdHTTP1.Get(get_url+'v', resp);

Why are you appending 'v' to the URL?  You are asking TIdHTTP to retrieve the URL 'http://www.yahoo.comv', and obviously the hostname 'www.yahoo.comv' does not exist, hence the error.

Also, note that http://www.yahoo.com redirects https://www.yahoo.com, so you need to have an SSLIOHandler component assigned to the TIdHTTP.IOHandler property, such as TIdSSLIOHandlerSocketOpenSSL.  Which TIdHTTP can handle for you, provided you have a suitable SSLIOHandler unit in your uses clause.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

 

TinyPortal © 2005-2018