Recent

Author Topic: Download a file from internet ...  (Read 968 times)

Espectr0

  • Full Member
  • ***
  • Posts: 217
Download a file from internet ...
« on: April 23, 2023, 04:48:17 pm »
Hola,

If I try to download a file from the internet from my app,
I get the exception "connection failed:443" in macOS while on Windows it works without problem.

Is it something I can solve or are they Apple limits?

Thanks

TRon

  • Hero Member
  • *****
  • Posts: 2435
Re: Download a file from internet ...
« Reply #1 on: April 23, 2023, 04:59:36 pm »
Hi Espectr0,

You really need to provide a little more information. There are many components/packages/solutions to download a file with Pascal. For all we know you are trying to execute wget and it fails returning that error for you (I do not use macos so have no idea but more information does help me in trying to search for a solution).

Even better would be if you would be able to share some code (but that's not always necessary to do so but would be preferred if you are able to). Other than that some information on what version of FPC/Lazarus and/or version of component/package that is used).

That way people are more inclined to provide a better answer (other hen pasting their own solution that works for them)

edit: Right now I can only answer with that your used solution seem unable to connect in secure way probably/perhaps missing (correct/supported version of) ssl libraries ?
« Last Edit: April 23, 2023, 05:09:18 pm by TRon »

Espectr0

  • Full Member
  • ***
  • Posts: 217
Re: Download a file from internet ...
« Reply #2 on: April 23, 2023, 06:14:53 pm »
Hola TRon,

used the following code:

Code: Pascal  [Select][+][-]
  1. fphttpclient, opensslsockets
  2. ...
  3.  
  4.   FDS := TFileStream.Create(AFileName, fmCreate);
  5.   try
  6.     try
  7.       FHTTPClient.HTTPMethod('GET', AURL, FDS, [200]);
  8.     except
  9.       on E: Exception do
  10.       begin
  11.       end;
  12.     end;
  13.   finally
  14.     FDS.Free;
  15.   end;
  16.  

to connect via https and download a file, as I always say, in Windows it works correctly but in macOS I get that expexion.


TRon

  • Hero Member
  • *****
  • Posts: 2435
Re: Download a file from internet ...
« Reply #3 on: April 23, 2023, 07:38:04 pm »
I have no idea how to check what could be the culprit (assuming that your used URL is valid and you are allowed to connect. Make sure to check firewall and file/application permissions perhaps even virus checker.).

Did you read https://wiki.freepascal.org/macOS_Programming_Tips#OpenSSL.2C_LibreSSL.2C_Secure_Transport.2C_Network_Framework ?

Espectr0

  • Full Member
  • ***
  • Posts: 217
Re: Download a file from internet ...
« Reply #4 on: April 23, 2023, 09:28:56 pm »
Thanks, I'll investigate how to use Apple's standard framework

ozznixon

  • Full Member
  • ***
  • Posts: 119
    • http://www.modernpascal.com/
Re: Download a file from internet ...
« Reply #5 on: May 21, 2023, 08:31:29 pm »
You could share the URL.


It could be simple things like - Datetime is invalid, Self Signed Certificate and OS is not set to allow, etc.


Posting the URL will allow us to help you.


Best Regards,
Ozz
---
Want to kick the tires to a Free Pascal like script engine? http://www.ModernPascal.com/

 

TinyPortal © 2005-2018