Click here to Skip to main content
15,902,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using urldownloadtofile to download a web content as below
CBSCallbackImplPX callback;
callback.nTitmeOut=10;		//"http://www.zoominfo.com/login","http://www.google.com"
if ( URLDownloadToFile( 0, "http://www.zoominfo.com/login", "a.html", 0,&callback ) != S_OK )
.
.
.
.
.

class CBSCallbackImplPX : public IBindStatusCallback 
.
.
.
.
.
//--------------------------------------------------------------------
STDMETHODIMP CBSCallbackImplPX::OnProgress(ULONG ulProgress,
										   ULONG ulProgressMax,
										   ULONG ulStatusCode,
										   LPCWSTR szStatusText)
{
	try{
	m_endDownload=clock();
	int nTimeTakenForThisDownload=0;
	nTimeTakenForThisDownload=((int)( m_endDownload -m_startDownload)/CLOCKS_PER_SEC) ;
	if(nTimeTakenForThisDownload>=nTitmeOut)
	{
		////CMTLog::WriteLogMT("Download cancelled by client");
		return E_ABORT;  // Download canceled by the client
	}
	return S_OK;
	}catch(...)
	{
	int x=0;
	}
}




I have used here callback function and checking for custom timeout through OnProgress()
It works fine ,If i give 20 sec time out or even 2 sec timeout it is coming after that time and it is been possible only because it frequently callsback OnProgress().

But if I try to open a page which have the probability to get time out before desired time.[like trying to open Zoominfo.com from a gateway where it is blocked]it is not calling OnProgress() for around 5 minute.

I have IE8 so as Microsoft told their default timeout in IE8 is 5 minute.
is that the reason for what I found that OnProgress() is not been called.
from urlmon.dll the call directly came to STDMETHODIMP_(ULONG) CBSCallbackImplPX::Release()?

Is there any way so that I need not to wait for 5 minute[only 20 sec is enough for me]
in case if the url is not responding?


for further details please refer to this link:
http://support.microsoft.com/kb/833301
Posted
Updated 20-Jun-11 23:26pm
v2

1 solution

The issue is resolved.
It was happening because Urldownloadtofile uses Internet explorer's api
and IE8 have default timeout of 5 minute [by default] so within this time it will listen to the port and will not call OnProgress() so I changed the IE default timeout
Reg path= HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\<br />
Internet Settings]<br />
create a <br />
name=ReceiveTimeout<br />
type=DWORD<br />
mode=decimal<br />
value=5000  [in milisecond]


and enjoy.... :)
 
Share this answer
 
v2

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