TScHttpWebRequest in a thread

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
Highfly
Posts: 1
Joined: Mon 21 Mar 2022 10:32

TScHttpWebRequest in a thread

Post by Highfly » Mon 21 Mar 2022 11:07

What is the correct way to use TScHttpWebRequests objects with threads?

I would like to make four simultaneous HTTPS GET requests to a web server. I have created a thread to use a TScHttpWebRequest object to generate the GET call.

If I run just a single thread, the GetResponse() method returns in ~500ms. All good so far. But if I start four threads in parallel, I note the following:
  • The first GetResponse() to return does so after ~4000ms
  • Subsequent threads return at 500ms intervals after the first one.

In other words, there's an unexplained delay before things start working, and then everything runs in sequence anyway: there seems to be something stopping the TScHttpWebRequest objects running in parallel.

Have I missed something? Or is there a better way to make parallel calls to a Web server?

Code: Select all

//-- Thread Execute() function (error checking code not shown)
void TMyThread::Execute()
{
  // Declarations
  TMemoryStream* memStream = new TMemoryStream();
  TScHttpWebRequest* Request = new TScHttpWebRequest(NULL);
  TScHttpWebResponse* Response;

  // Execute HTTPS "GET" call
  Request->RequestUri = sURL;           // sURL is defined elsewhere
  Response = Request->GetResponse();

  // Process the response
  Response->ReadToStream(memStream);
  memStream->SaveToFile(sFilename);     //sFilename is defined elsewhere

  // Tidy up
  Request->Disconnect();
  delete Response;
}

Raudar
Devart Team
Posts: 19
Joined: Fri 02 Apr 2021 11:04

Re: TScHttpWebRequest in a thread

Post by Raudar » Tue 22 Mar 2022 15:38

Hi there,

Unfortunately, we could not reproduce the issue on our side. Work speed in a separate thread should be equal to the speed in the main one.

Please send us a full sample for investigation along with the way you track the speed of the response.

Best Regards,

Devart Support

Post Reply