lwinkenb
asked on
CHTTPFile::SendRequest problem
I am using CHTTPFile::SendRequest to Post data to a website. This seems to work fine about 3/4 of the time. The problem is that after posting 2 or 3 pages, the next page I try to post wont work. It will just hang on the SendRequest call untill finally an exception is thrown with the error text, "The operation timed out".
I have a couple questions:
1 ) When this happens it takes about 3 minutes for the operator to time out. Is there any way I can shorten this time? 3 minutes is ridicuously too long, as a successful call takes less than 2 seconds.
2) Why is this timing out at all? It happens like clockwork; after 2-4 successful calls, I will have this problem. It is always the same error (The operation timed out). I know that the server is still accessible, because I can open another instance of my program and post data just fine.
Here is pseudo code on how I perform my post operation:
CInternetSession session;
CHTTPConnection* m_pWebConnection;
CHTTPFile* m_pWebFile;
CString m_strWebHeaders = _T("Content-Type: application/x-www-form-url encoded");
m_pWebConnection = session.GetHttpConnection( ...);
m_pWebFile = m_pWebConnection->OpenRequ est(CHttpC onnection: :HTTP_VERB _POST,<som e string>);
try {
m_pWebFile->SendRequest(m_ strWebHead ers,<data> , <data length>); // this will time out about 3/4 of the time
}
catch(CInternetException * pe)
// This is where it catches the timout error
I have a couple questions:
1 ) When this happens it takes about 3 minutes for the operator to time out. Is there any way I can shorten this time? 3 minutes is ridicuously too long, as a successful call takes less than 2 seconds.
2) Why is this timing out at all? It happens like clockwork; after 2-4 successful calls, I will have this problem. It is always the same error (The operation timed out). I know that the server is still accessible, because I can open another instance of my program and post data just fine.
Here is pseudo code on how I perform my post operation:
CInternetSession session;
CHTTPConnection* m_pWebConnection;
CHTTPFile* m_pWebFile;
CString m_strWebHeaders = _T("Content-Type: application/x-www-form-url
m_pWebConnection = session.GetHttpConnection(
m_pWebFile = m_pWebConnection->OpenRequ
try {
m_pWebFile->SendRequest(m_
}
catch(CInternetException * pe)
// This is where it catches the timout error
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks roshmon, ill give that a try to set the timeout. Any ideas why it would timeout in the first place?
ASKER
well, I think I just figured out my problem. I wasnt closing my CHTTPFile after the method ended. When I started closing it, the timeouts stopped.
Well learning how to set the timeout was worth 500 points to me :)
Well learning how to set the timeout was worth 500 points to me :)
>> I wasnt closing my CHTTPFile after the method ended.
Ohh yes, that could be the actual problem.
Thankx
Ohh yes, that could be the actual problem.
Thankx
session.SetOption(INTERNET
Rosh :)