Recent

Author Topic: HttpClient  (Read 1656 times)

gilsonalencar

  • New Member
  • *
  • Posts: 48
HttpClient
« on: September 30, 2022, 01:11:16 pm »
Hellow Everybody,

I need to use a HttpClient resource to get a simple text file content from a server to the android app. I tried jHttpClient component, but nothing is returned.  I tried the fphttpclient lib but it freezes. The code with fphttpclient is very simple as show below:

URL:='http:// ....'
StrList: TStringList

with TFPHttpClient.Create(nil) do
begin
   StrList:=TStringList.Create;
   Get(URL, StrList)
   .
   .
   .
end;

The same code works well with standard Lazarus running in Debian Linux but in  Android with LAMW freezes after Get(URL) command. Any sugestion?   
   
   

gilsonalencar

  • New Member
  • *
  • Posts: 48
Re: HttpClient
« Reply #1 on: October 02, 2022, 05:34:39 pm »
The LAMW Apps appears to be not connected to the Internet in the smartphone. AndroideManifest was checked and its ok. I don't understending what is happening with the App connection.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: HttpClient
« Reply #2 on: October 12, 2022, 11:46:41 am »
Always check logcat, Android logs even native calls.

gilsonalencar

  • New Member
  • *
  • Posts: 48
Re: HttpClient
« Reply #3 on: October 13, 2022, 12:13:28 am »
There is no problem with Internet connection in android. The function jHttpClient is really not working.  In contrast, httpsend from synapse package is working for a http request, but https not. This is my problem now.

HttpGET: THTTPSend;
URL:='https://www ......';

My simple code is:
  HttpGET:=THTTPSend.Create;
  HttpGET.Sock.CreateWithSSL(TSSLOpenSSL);
  HttpGET.Sock.SetTimeout(5);
  HttpGET.Sock.SSLDoConnect;
  teste:=HttpGET.HTTPMethod('GET', URL);

Once again, the same code works well in Linux. In android, a https request is returning nothing. Is there some thing related with android and Linux openssl lib? 

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: HttpClient
« Reply #4 on: October 13, 2022, 06:10:35 am »
In android, a https request is returning nothing. Is there some thing related with android and Linux openssl lib?
The library version might matter. OpenSSL has many "living" versions: 3.0, 1.1.X and at some rare occasions, 1.0.X. Perhaps get the raw SSL handshake result. But before that, does it return any HTTP status?

Mongkey

  • Sr. Member
  • ****
  • Posts: 430
Re: HttpClient
« Reply #5 on: October 13, 2022, 05:17:13 pm »
There is no problem with Internet connection in android. The function jHttpClient is really not working.  In contrast, httpsend from synapse package is working for a http request, but https not. This is my problem now.

HttpGET: THTTPSend;
URL:='https://www ......';

My simple code is:
  HttpGET:=THTTPSend.Create;
  HttpGET.Sock.CreateWithSSL(TSSLOpenSSL);
  HttpGET.Sock.SetTimeout(5);
  HttpGET.Sock.SSLDoConnect;
  teste:=HttpGET.HTTPMethod('GET', URL);

Once again, the same code works well in Linux. In android, a https request is returning nothing. Is there some thing related with android and Linux openssl lib?

Better walking arround with jfhttpclient, if you want a challenge, this could be a hard challenge, make fpc httpclient live inside android  :D, rancak bana nian if it could happen! On previous thread i already make almost the same thread like this. Talking httpclient with null result on any methods, literally.

Jhttpclient working very well, i use it almost in all of my internet related projects.
« Last Edit: October 13, 2022, 05:20:16 pm by Mongkey »

 

TinyPortal © 2005-2018