Search code examples
androiddelphiindydelphi-xe6idhttp

Socket Error #113 No route to host on Android


In a Delphi XE6 FireMonkey app, when I press the button, I get the following error on Android:

Socket Error #113 No route to host

procedure TForm1.Button1Click(Sender: TObject);
var
  Intent: JIntent;
  datosPost: TIdMultiPartFormDataStream;
  mRespuestaPost: String;
begin
  try
    datosPost := TIdMultiPartFormDataStream.Create;
    datosPost.AddFormField('usuario', txtUser.Text);
    datosPost.AddFormField('password', txtPass.Text);
    mRespuestaPost := DataModule2.IdHTTP.Post
      ('http://X.X.X.X/CGLB/ac.php', datosPost);
    ShowMessage(mRespuestaPost);
  finally
    datosPost.Free;
  end;
end;

Does the TIdHTTP component require another component to work?


Solution

  • The application failed to connect with x.x.x.x

    To verify the error, try connecting to the host x.x.x.x from the same computer, using a web browser, or Telnet on port 80. If a normal web browser can not connect, Indy TIdHTTP will not be able too. (Ping is not useful for http)

    Note: on Android, use the built-in default browser to do the test. Also check that the app permissions include the permission INTERNET.