I have an application that retrieves a single image over HTTP from a
video server every 60 seconds. This is does over GPRS so at times can be
a little slow, but in general there are no issues.
I'm using the THttpCli component to get the Get( ) the images within
BDS2006, C++ flavour.
However, very occasionally I am seeing that my method that gathers these
images never finishes, and I'm pretty sure the cause is the Get( )
method in the THttpCli.
No exception is thrown, but the method just never returns, and therefore
the method hangs indefinitely. (2 days and counting)
Is this 'normal' behaviour? Can it be detected and dealt with?
The basic operation of what I'm doing is this:
void __fastcall cImageCaptureClass::me_TimeoutTimerTimer(TObject *Sender)
{
cLoggerClass * cl_LoggerClass = cLoggerClass::Instance( ); //
Logger Singleton
try
{
// Set the HTTP paramaters ready for connection
co_HttpClient->Location = at_FileName;
co_HttpClient->Username = at_UserName;
co_HttpClient->Password = at_Password;
co_HttpClient->URL = "http://" + at_SnapshotIP
+ "/axis-cgi/jpg/image.cgi?streamprofile=" + at_ImageProfile;
co_HttpClient->Connection = "Keep-Alive";
co_HttpClient->Get( );
if (IntToStr(co_HttpClient->StatusCode) == 200) // The only
code that matters to me
{
cl_LoggerClass->me_AddLog("Snapshot Status: 200 OK",
cLoggerClass::LOG_TYPE_SUCCESS, cLoggerClass::LOG_LEVEL_RELEASE);
// A valid reply? Ok, so delete the old image, and copy
this temp file as the new image
try
{
if (FileExists(at_FinalFileName)) // We have an old image?
{
DeleteFile(at_FinalFileName); // Remove old image
} // else nothing to remove
CopyFile(at_FileName.c_str( ), at_FinalFileName.c_str(
), false); // Copy new image
}
catch ( ... ) // File Delete/Copy failed. Doesn't matter why.
{
cl_LoggerClass->me_AddLog("Snapshot: Error updating new
file!", cLoggerClass::LOG_TYPE_ERROR, cLoggerClass::LOG_LEVEL_RELEASE);
}
}
else // Not 200 reply? Something failed then. Doesn't really
matter what.
{
cl_LoggerClass->me_AddLog("Snapshot: Aborted with Status: "
+ IntToStr(co_HttpClient->StatusCode) + " ERROR",
cLoggerClass::LOG_TYPE_ERROR, cLoggerClass::LOG_LEVEL_RELEASE);
}
}
catch ( ... ) // co_HttpClient->Get( ) failed. Doesn't matter why.
{
cl_LoggerClass->me_AddLog("Snapshot: Can't Get: " +
IntToStr(co_HttpClient->StatusCode) + " ERROR",
cLoggerClass::LOG_TYPE_ERROR, cLoggerClass::LOG_LEVEL_RELEASE);
}
}
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be