TfpHttpclient and the way openssl is handled have changed considerably since fpc 2.7.1
The example in the wiki can be reduced to:
{$mode delphi}{$ifdef windows}{$apptype console}{$endif}
uses
fphttpclient,
openssl,
opensslsockets;
var
Client: TFPHttpClient;
begin
Client := TFPHttpClient.Create(nil);
try
Client.AddHeader('User-Agent', 'Mozilla/5.0 (compatible; fpweb)');
{ Allow redirections }
Client.AllowRedirect := true;
writeln(Client.Get('https://google.com/'));
finally
Client.Free;
end;
end.
Tested.
OpenSSL initialization is automatic in 3.2.0 or higher. FPC 3.3.1 can use openssl 3.
Ergo: the wiki needs an overhaul, it is not current.
Lazarus version, add lcl to your project dependencies.:
program clienttest;
{$mode delphi}{$ifdef windows}{$apptype console}{$endif}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
Interfaces,lclintf, sysutils,classes,fphttpclient,openssl,opensslsockets;
var
Client: TFPHttpClient;
List:TStringList;
begin
Client := TFPHttpClient.Create(nil);
List := TStringlist.Create;
try
Client.AddHeader('User-Agent', 'Mozilla/5.0 (compatible; fpweb)');
{ Allow redirections }
Client.AllowRedirect := true;
List.Text:=Client.Get('https://google.com/');
List.SaveToFile('c:\users\public\atest.html'); // change paths for Linux. './atest.html';
OpenURL('C:\users\public\atest.html');
finally
List.Free;
Client.Free;
end;
end.
If there are still problems with the connection to your server, let me know: I do not have such a device, so I basically need to know what protocol it uses and what port. At least now you have client code that is known to work.
I have many Raspberry's that run server code that can connect in the same way as above.
Note this code
requires a recent OpenSSL and I used OpenSSL 3.
If it works against google, you can be assured there is no communications problem at the client side.
Plz use a port above 1000, though as per IANA documentation. Port 633 is reserved for service status updates.
Your original 4000 should be OK.