Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CHTTPFile::SendRequest problem

Posted on 2003-10-26
5
Medium Priority
?
2,638 Views
Last Modified: 2013-11-20
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-urlencoded");
m_pWebConnection = session.GetHttpConnection(...);
m_pWebFile = m_pWebConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,<some string>);
try {
  m_pWebFile->SendRequest(m_strWebHeaders,<data>, <data length>);  // this will time out about 3/4 of the time
}
catch(CInternetException * pe)
// This is where it catches the timout error      
0
Comment
Question by:lwinkenb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 2000 total points
ID: 9622090
Did you tried
CHttpFile::SetOption with flag "INTERNET_OPTION_CONNECT_TIMEOUT"

Rosh :)
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9622099
Try this one for 20 seconds

session.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, 1000 * 20);

Rosh :)
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 9623450
thanks roshmon, ill give that a try to set the timeout.  Any ideas why it would timeout in the first place?
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 9623486
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 :)
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9624792
>>  I wasnt closing my CHTTPFile after the method ended.
Ohh  yes, that could be the actual problem.

Thankx
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question