TIdHTTP's Get-method locks ?

Giganews Newsgroups
Subject: TIdHTTP's Get-method locks ?
Posted by:  …@tas.de
Date: Tue, 21 Aug 2007

Hello,

I'm using TIdHTTP and its Get method to get data in JPEG format from
webcameras. For each webcam a seperate TThread is startet, which then uses
TIdHTTP to get the image data. This works fine in general, but I've got a
problem with an Axis camera, because after some hours this camera stops
responding. The get method, which is embedded in a try...catch block, starts
now throwing the exception "Read timeout" when trying to fetch data from the
camera. Then, after a while, get exists with a single EIdSocketError #10054.
The next call of get seems to crash my TThread completely, although the
exception should be catched. This thread produces no more output, while all
other threads continue to run.
My first thought was that the get-method blocks my thread, but that can't be
the case, because each get is guarded by a second TThread which disconnects
the TIdHTTP instance after a specific time.
I'm using Codegear's C++ Builder 2007 with Indy 10.1.5 . Am I doing
something wrong ?

The following is a summary of the code I'm using in each TThread. The output
method uses SendMessage to generate the output in the main window. event_p
and timeout_event_p are from class TEvent.

while(!Terminated){
    mem_p->Position = 0;    // Reset TMemoryStream
    // Start a second thread to prevent get blocking the thread
    http_timeout_thread_p = new http_timeout_thread_c(timeout_event_p,
HTTP_Client_p);

    i_ui = HTTP_CODE_OK;

    try{
      // command_s is an AnsiString containing the URL
    HTTP_Client_p->Get(command_s, mem_p);
    }
    catch(EIdHTTPProtocolException &e){
    i_ui = e.ErrorCode;
    output(e.Message);
    }
    catch(Exception &exception){
        output(exception.Message);
    }

    // Stop monitor thread
    timeout_event_p->SetEvent();
    http_timeout_thread_p->Terminate();
    if (http_timeout_thread_p->WaitFor()){
    i_ui = 0;
    output("Timeout");
    }//endif
    delete http_timeout_thread_p;
    timeout_event_p->ResetEvent();

    if (i_ui != HTTP_CODE_OK){
        // error handling
    }else{
        // Do something with the data in mem_p
    }
    mem_p->Clear();

    if (event_p->WaitFor(1) == wrSignaled) break;
}

Any help would appreciated.

Bye, Eike

Replies