Click here to Skip to main content
15,919,121 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
When i am using GetHttpsConnection API in a c++ program, i got an exception(CInternetException) "The operation timed out". I don't know the reason for it. Can anyone help me?
code section:
C++
	CInternetSession	oInternetSession(_T("Watchdog"));
	UINT				nBytesRead ;
	CHttpConnection*    pConnection	= NULL;
	CHttpFile*          pHttpFile	= NULL;
	CString             strUserName = _T("");
	CString             strPassword = _T("");
	DWORD               dwStatusCode;
	char*               chBuffer    = new char[1024];
	CString             strLog;

	try 
	{
		pConnection = oInternetSession.GetHttpConnection(m_strHttpServer, 
		(INTERNET_PORT) m_nHttpPort, strUserName, strPassword);

		//Open Request and get the HttpFile
		pHttpFile   = pConnection->OpenRequest(1, m_strHttpObjectName ,NULL, 1, NULL,   NULL,INTERNET_FLAG_RELOAD); 
		//Send Request
		pHttpFile->SendRequest();
}
catch(CInternetException* pe)
{
	TCHAR ExcText[1024];
	pe->GetErrorMessage(ExcText, 1023);
	TRACE(_T("WinInet exception %s\n"), ExcText);
	strLog.Format(_T("Accessing Url: %s:%d/%s failed. Reason: %s"), m_strHttpServer,m_nHttpPort, m_strHttpObjectName, ExcText);
	m_pLogger->Log(LOGPRIO_HIGH, strLog);
	pe->Delete();
}

Thanks.
Posted

1 solution

I'm not C# C++ guy. You just try to increase timeout(only little bit). And refer these for more details
CInternetSession Class[^]
Retrieving a file via. HTTP[^]
 
Share this answer
 
v2
Comments
SajeeshCheviry 6-Jan-14 0:35am    
Thanks for your response :-)
thatraja 6-Jan-14 1:59am    
welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900