Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 91,610
» Latest member: hethongkhovatlieucom
» Forum threads: 2,418
» Forum posts: 11,355

Full Statistics

Online Users
There are currently 697 online users.
» 0 Member(s) | 694 Guest(s)
Applebot, Bing, Google

Latest Threads
How to terminate HTTP Thr...
Forum: Indy
Last Post: hamstring
Today, 05:14 AM
» Replies: 4
» Views: 304
VCL conversion
Forum: Delphi General Discussion
Last Post: marktuan
08-07-2026, 01:20 PM
» Replies: 0
» Views: 364
Looking for UI Design Tip...
Forum: Delphi General Discussion
Last Post: chrisjordon232
08-06-2026, 05:17 AM
» Replies: 0
» Views: 84
Simply convert PeerIp to ...
Forum: Indy
Last Post: DidierMenant
08-04-2026, 03:50 PM
» Replies: 2
» Views: 247
New CGDevTools build is a...
Forum: CGDevTools
Last Post: lfeliz
08-04-2026, 12:03 AM
» Replies: 2
» Views: 1,399
IW 16.2.0 Missing librari...
Forum: IntraWeb General Discussion
Last Post: JuergenS
07-31-2026, 09:44 AM
» Replies: 6
» Views: 1,311
Datatables question
Forum: IntraWeb General Discussion
Last Post: Alexandre Machado
07-28-2026, 04:34 AM
» Replies: 2
» Views: 300
CSS file not reloading af...
Forum: IntraWeb General Discussion
Last Post: CharlieDunn
07-27-2026, 08:27 PM
» Replies: 1
» Views: 485
Intraweb components missi...
Forum: IntraWeb General Discussion
Last Post: valmeras
07-27-2026, 03:18 PM
» Replies: 3
» Views: 431
Image question on tiwjqdb...
Forum: IntraWeb General Discussion
Last Post: alex.trejo@tttnet.com.mx
07-17-2026, 05:18 PM
» Replies: 6
» Views: 4,924

 
  Basic Authentication Error
Posted by: staff@ergosoft.it - 12-04-2023, 11:20 AM - Forum: Indy - Replies (2)

Hi,

I have a problem on a API REST call.

I always get the authentication error: HTTP/1.1 401 Unauthorized

this is my code in delphi 11.3

thanks
Alessandro Romano
//-----------------------------------------------------------
var
lHTTP: TIdHTTP;
SSL : TIdSSLIOHandlerSocketOpenSSL;
Comando, RisultatoPost : Ansistring;
lPostData: TStringStream;
base64: TBase64Encoding;
myUser, MyPass : string;
begin
  Comando := 'https://apirest... etc';
  base64 := TBase64Encoding.Create(0);

  myUser := 'myuser';
  MyPass := 'mypass';

  lPostData := TStringStream.Create('', TEncoding.UTF8);
  with TJSONObject.Create do
  try
      AddPair('Authorization', 'Basic ' + base64.Encode(myUser + ':' + MyPass));
      lPostData.Writestring(ToJSON);
  finally
    Free;
  end;

  lPostData.Position := 0;
  try
    lHTTP := TIdHTTP.Create;
    SSL := TIdSSLIOHandlerSocketOpenSSL.Create(lHTTP);
    SSL.SSLOptions.Method := sslvTLSv1_2;

        lHTTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(lHTTP);
        lHTTP.IOHandler := SSL;
        lHTTP.HandleRedirects := True;
        lHTTP.Request.CustomHeaders.Clear;
        lHTTP.Request.CustomHeaders.FoldLines := False;
        lHTTP.Request.Accept := 'application/json';

        //lHTTP.Request.ContentType := 'application/json';
        //lHTTP.Request.CharSet := 'UTF-8';

        RisultatoPost := lHTTP.Post(Comando, lPostData);
         

    finally
      SSL.Free;
      lHTTP.Free;
      lPostData.Free;
      base64.Free;
  end;

Print this item

  Does Indy send and receive Raw Ethernet II frames?
Posted by: JFrancis - 12-01-2023, 05:45 PM - Forum: Indy - Replies (1)

Hi There,

     I work for a company that uses Raw ethernet frames to control hardware. I'm trying to find a way to send the frames and also receive them. I've gotten a little lost trying to use npcap to do this and I'm wondering if Indy has the capability to do this. 

As a clarification: I just need it to send a frame of [send to MAC][sent from MAC][etc.......]

Has anyone done this here before?

Print this item

  PosEX dosn't work on 64-bit
Posted by: mondoedp - 11-30-2023, 11:20 AM - Forum: IntraWeb General Discussion - Replies (9)

Hello,
I'm just trying new 15.5.2 version that resolved some issues.
I use Delphi 10.2 Tokyo.

Going forward on my tests, I noticed that, when I compile in 64-bit platform, the function StrUtils.PosEx doesnt'work properly.
(I don't call it directly, but it's used (for example) in System.IOUtils (TPath, TDirectory, TFile)).

By example:
PosEx(':','C:\SVN\Mydirectory',3) return 2 (that is the right value if I call PosEx(':','C:\SVN\Mydirectory',1))
while it must return 0 (as 32-bit does).
Also notes that in a normal vcl application (no-intraweb) it works in 64-bit too.

Perhaps it depends by some directive but I wasn't able to find it.

Could you have a check?
Thanks
Alberto Pilat

Print this item

  Add attribute to <html> or <body> tag
Posted by: RenSword - 11-30-2023, 04:01 AM - Forum: IntraWeb General Discussion - No Replies

Is is possible to add attribute to <html> or <body> tag? and change it at runtime
For example
IWForm1.AddAttribute('data-mode="edit"');
>>>>
<html data-mode="edit"> or <body data-mode="edit">

Print this item

  About Indy 10 TIdTCPServer and ramdom disconections
Posted by: PabloRomero - 11-29-2023, 05:24 PM - Forum: Indy - Replies (2)

Dear Indy People.

I have a serious problem and I can't find any information.

I have a service made with Delphi and Indy 10. I made it with TIdTCPServer.

It's a service that controls licenses with a "keep alive". Everything is based using the TIdTCPClient that runs the applications, exchanging information with the server service.

They always exchange XML based structures, like text. In this XML, there is a "command" property. This property receives every 15 minutes the command
"Keep" and the server answers "ok, here I am, Keep ok" and gives to the station that runs my application, status and login information.

All the information is stored in memory in a structure based on Tlist<Types>.

We know that there are threads that are executed in the TidTCPExecute event for each connection.

In my services there are another parallel threads inside the service, to maintain it, renew licenses and clean up unused licenses.

Everything accesses structures based on that Tlist<Lot of Types>. There are of course, other data sharewd by all those threads.

Everything works ok.

But...

Here comes the problem. My application disconnects randomly, to some workstations. I suspect it must be because of the way I protect the structures and data shared by the threads.

Going in detail

We have the IdTCPServerExecute event

Code:
var
    ClientIPAddr: string;

begin
      if not Server.Active then
        exit;

      ClientIPAddr := AContext.Binding.PeerIP;    //ip
      xComando.Linea := fxLeerLinea; //read the line
      if xComando.Linea = '' then 
      begin
        LimpiamosBuffer(AContext); //clean up buffer
        exit;
      end;

      xComando.EsXML := fxEsXML( xComando.Linea ); //is an xml what is coming

      if xComando.EsXML then
        TManejoPaquetesDOM.Procesa( xComando.Linea, Acontext, Server ) //process de estructure and comand. See below
      else
      begin
        TumbarIP(ClientIPAddr);    //clean the connection
        exit;
      end;
      xComando.Linea := ''; //clean line
end;


The "TManejoPaquetesDOM.Procesa( xComando.Linea, Acontext, Server )" is a class like this


Code:
  TManejoPaquetesDOM = class(TIdSync)
  protected
    fLinea: string;
    FContexto: TIdContext;
    FServer  : TIdTCPServer;
    FDespacho: IXMLPaqueteType;

    function  TomaObjXML( linea: string ): IXMLPaqueteType;
    function  fxComandoSoportado( const sComando: string ): boolean;
    procedure EnviaXML;
    procedure AltaEstacion;
    procedure EnvioModulos;
    procedure KeepAlive;
    procedure Informe;
    procedure LLSNoDisponible( pMantenimiento: boolean = false );
    procedure LoginEstacion;
    procedure LimpiaPaquete;
    procedure prExitSesion( pAccion: TManejoSesion; msg : string = '' );
    procedure DoSynchronize; override;

  public
    constructor Crear(linea: string; AContext: TIdContext; pServer: TidTCPServer );
    class procedure Procesa(Linea: string; AContext: TIdContext; pServer: TidTCPServer );
  end;

The "DoSynchronize" does all the work with each connection receive from clients.


Code:
class procedure TManejoPaquetesDOM.Procesa(Linea: string; AContext: TIdContext; pServer: TidTCPServer );
// with this class procedure we manage the thread
begin
    with Crear(linea, AContext, pServer ) do
    try
      Synchronize;
    finally
      Free;
    end;
end;

//the constructor creates, passes the data and parses the XML that brings each station
constructor TManejoPaquetesDOM.Crear(linea: string; AContext: TIdContext; pServer: TIdTCPServer );
begin
    inherited Create;
    fLinea    := linea;

    FContexto  := AContext;
    FContexto.Connection.IOHandler.DefStringEncoding := IndyTextEncoding_UTF8;

    FServer    := pServer;
    FDespacho  := TomaObjXML( linea );
end;


As you can see, "TManejoPaquetesDOM = class(TIdSync)". This is who processes everything. As I understand it, TidSync makes all the other threads
of IdTCPServerExecute threads wait for it to finish.

I'm not sure if this is the best approach, ideally the process should be parallel without making anyone wait.

All the structures when accessed by the other threads of my application are protected with a generic class I made
like this


Code:
  TControlBloqueos = class
  private
    FLlave: TCriticalSection;
  public

    constructor Create;
    destructor Destroy; override;

    procedure Lock;
    procedure Unlock;
  end;

implementation

constructor TControlBloqueos.Create;
begin
  inherited;
  FLlave := TCriticalSection.Create;
end;

destructor TControlBloqueos.Destroy;
begin
  Fllave.Free;
  inherited;
end;

procedure TControlBloqueos.Unlock;
begin
  Fllave.Leave;
end;

procedure TControlBloqueos.Lock;
begin
  Fllave.Enter;
end;

Each time the data shared by threads are accessed, those threads protect the data with an instance of this class, global to the whole service.

This instance is created at the start of the service

Code:
Bloqueo :=  TControlBloqueos.Create;


and all the threads accessing the data, proceed like this.


Code:
Bloqueo.lock;
try
    //process shared data between threads
finally
    Bloqueo.unlock;
end;


My problem is that I can't detect those random disconnections of some users from my system.

My questions

a) Is there a way to speed up what IdTCPServerExecute does? Not using TidSync?

b) What is the best way to protect shared data between threads? I'm not sure what I did is the best approach.

Regards
Pablo Romero

Print this item

  IntraWeb training courses
Posted by: KUD1990 - 11-29-2023, 03:08 PM - Forum: IntraWeb General Discussion - No Replies

Hello everyone, 

can you tell me please if you can recommend me some courses for IntraWeb. On german language will be better because my english ist not to good. 

Thank you and have a nice day


Kind regards

Print this item

  IWSessionTimeout page not show on IIS when session timeout
Posted by: baxing - 11-29-2023, 02:37 PM - Forum: IntraWeb General Discussion - Replies (1)

Hi,

I use timeout template file(IWSessionTimeout.html) in my Templates folder. I test on my local computer by myapp.exe (indy), It show timeout page normally. But I built to myapp.dll and used on my server by IIS. When Timeout occurs, it doesn't show the timeout page, but shows Server Error : 500 - Internal server error instead (There is a problem with the resource you are looking for, and it cannot be displayed.).

I don't know if for ISAPI there needs to be any additional adjustments or not in order to display the Timeout template page when a Timeout occurs because for Indy it displays normally.

Guide me please.

Thank you.

Print this item

  Lazarus IMAP i got error
Posted by: eldonfsr - 11-28-2023, 05:31 PM - Forum: Indy - Replies (1)

Hello i tried to read email with idimap indy on lazarus but i get this error..
 
unable to execute command  wrong connection state, current connection state authenticated 

procedure TFormMain.getunreademails(Sender: TObject);
Var  lj,i,id,attachs:Integer;
    CurrUId:String;
    msg: TIdMessage;
    BodyTexts: TStringList;
    lParts:TIdImapMessageParts;
    SearchInfo: array of TIdIMAP4SearchRec;
begin
//  if( IdIMAP.Connected=false) then begin
//    IdIMAP.Disconnect();
//    sleep(200);
//    IdIMAP.Connect();
//    FolderList:= TStringList.Create;
//    IdIMAP.StatusMailBox('Inbox', IdIMAP.MailBox);
//    IdImap.ListMailBoxes(FolderList);
//    IdImap.SelectMailBox('Inbox');
//  end;

  if(IDIMAP.Connected=false) then begin;
    SetLength(SearchInfo, 1);
    SearchInfo[0].SearchKey := skUnseen;
    IDIMAP.UIDSearchMailBox(SearchInfo);
  end else begin
    SetLength(SearchInfo, 1);
    SearchInfo[0].SearchKey := skUnseen;
    IDIMAP.UIDSearchMailBox(SearchInfo);  // here is generated the error
  end;
  lParts := TIdImapMessageParts.Create(nil);
  if( IDImap.Connected=true) then begin
    for i := 0 to High(IDIMAP.MailBox.SearchResult) do begin
        MSG := TIdMessage.Create(nil);
        Id:=IDIMAP.MailBox.SearchResult[i];
        CurrUId:=Inttostr(IDIMAP.MailBox.SearchResult[i]);
        try

            if( not BdEmails.Locate('UID', currUID , [loCaseInsensitive])) then begin
              IDIMAP.UIDRetrieve( CurrUID, msg );
              IDImap.UIDRetrieveStructure(Inttostr(IDIMAP.MailBox.SearchResult[i]), lParts);
              attachs:=0;
              for lj := 0 to msg.MessageParts.Count - 1  do begin
                if msg.MessageParts.Items[lj] is TIdAttachment then  begin
                    if( lParts[lJ].FileName <>'') then begin
                        Inc(attachs);
                        IDImap.UidRetrievePartToFile(Inttostr(IDIMAP.MailBox.SearchResult[i]), lParts[lJ].ImapPartNumber, i , Path+'emails\attach\'+lParts[lJ].FileName, lParts[lJ].ContentTransferEncoding);
                        BDAttachs.Append;
                        BDAttachs.FieldByName('Account').AsString  :=BDAcct.FieldByName('emailAcc').AsString ;
                        BDAttachs.FieldByName('ID').AsInteger      :=id ;
                        BDAttachs.FieldByName('UID').AsString      := CurrUID;
                        BDAttachs.FieldByName('Attachs').AsInteger := lj;
                        BDAttachs.FieldByName('FileName').AsString := lParts[lJ].FileName;
                        BDAttachs.post;
                    end;
                  end;
              end;
//              fileName_MailSource := TmpFolder  + Inttostr(IDIMAP.MailBox.SearchResult[i])+ '.eml';
              BDEmails.Append;
              BDEmails.FieldByName('Account').AsString  := BDAcct.FieldByName('emailAcc').AsString;
              BDEmails.FieldByName('ID').AsInteger      := id;
              BDEmails.FieldByName('UID').AsString      := currUID ;
              BDEmails.FieldByName('Date').AsDateTime  := msg.Date;
              BDEmails.FieldByName('subject').AsString  := msg.Subject;
              BDEmails.FieldByName('attachs').AsInteger  := attachs;
              BDEmails.FieldByName('fromaddr').AsString := msg.From.Address;
              BDEmails.post;
          end;

        finally
          MSG.Free;
        end;

    end;
  end;
  BDEmails.First;

end;         


some examples to read unseen emails.... still using query search,.. or what i need to change to get that...

i can not download documentation of indy...

thanks..
any help great...



Attached Files Thumbnail(s)
   
Print this item

  How to make a Delphi Intraweb IWFrames work with IWTemplateProcessorHTML?
Posted by: Noobi$$ - 11-28-2023, 04:55 PM - Forum: IntraWeb General Discussion - Replies (1)

Hi all...
this is my first post I guess..

I'm using Delphi 11.3 with IW15.

I have multiple iwframes, using them as a body of my page beside a header and a footer. everything is working great until I decided to use IWTemplateProcessorHTML.

My problem is that each iwframe has a IWFrameRegion which cannot be renamed for some reasons (I don't know why), although I tried to rename it various ways however it's not renamable! for that it's impossible to apply a template for each iwframe because it will have the same file name IWFrameRegion.html therefor it will work only for one iwframe only!
Another try was by adding another IWRegion and then easily rename it after that applying the IWTemplateProcessorHTML on it but in the end, it renders nothing! (empty page).

Hence, this is how I call the iwframe to display it inside the body region:
  if frm1 = nil then
    begin
      frm1 := TIWFrame2.Create(self);
      frm1.Parent := IWRegion1;
      frm1.Visible := true;
    end;

So how to solve this issue? is my approach wrong? or there is another way to apply IWTemplateProcessorHTML to an iwframe? 

I've also attached a simple file for the problem.

Thanks.



Attached Files
.zip   FramesTest.zip (Size: 74.25 KB / Downloads: 4)
Print this item

  IntraWeb 15.5.2 is out!
Posted by: Alexandre Machado - 11-27-2023, 05:58 AM - Forum: IntraWeb General Discussion - Replies (6)

Hi guys,

a few bugs fixed and there is a new update available:

https://www.atozed.com/2023/11/intraweb-15-5-2/

Enjoy!  Big Grin

Print this item