Discussion:
does INTERNET_OPTION_CONNECT_TIMEOUT work or not?
(too old to reply)
Joe
2004-12-28 03:23:28 UTC
Permalink
Hi,

I've read that
INTERNET_OPTION_CONNECT_TIMEOUT

never used to work but does now, however I can't get it functioning. I've
downloaded and compiled the MS TEAR example

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/html/_sample_mfc_tear.asp

and added

BOOL bret=session.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,0);

after AfxParseURL (line 212).



Would someone confirm whether it works and if so please post some code
amendments to confirm that
I can get it working on my machine?

I have 6.0.2800.1405 of wininet.dll

Thanks
Brian Combs
2004-12-31 15:03:51 UTC
Permalink
Hello
The answer is yes and no.
176420 BUG: InternetSetOption Does Not Set Timeout Values
http://support.microsoft.com/?id=176420

For IE 6.x the different timeout settings should be all fixed for HTTP
however FTP may still fail. Also be aware that this is only connnect
timeout and you should also set the other timeout settings.
INTERNET_OPTION_CONNECT_TIMEOUT
INTERNET_OPTION_RECEIVE_TIMEOUT
INTERNET_OPTION_SEND_TIMEOUT

I also don't know if MFC is doing anything that is keeping from being set
correctly. You can use debug build of WinInet to get a trace and see what
is happeing.,

884931 How to use the debug version of the Wininet.dll file for Internet
http://support.microsoft.com/?id=884931

Thanks
Brian [MSFT]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Joe" <***@home.com>
| Newsgroups: microsoft.public.inetsdk.programming.wininet
| Subject: does INTERNET_OPTION_CONNECT_TIMEOUT work or not?
| Date: Tue, 28 Dec 2004 03:23:28 -0000
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| Lines: 32
| Message-ID: <41d0d1b0$0$19158$***@news-text.dial.pipex.com>
| NNTP-Posting-Host: 81-86-229-91.dsl.pipex.com
| X-Trace: 1104204209 news-text.dial.pipex.com 19158 81.86.229.91:4157
| X-Complaints-To: ***@uk.uu.net
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!tornado.fastwebnet.it!tiscali!new
sfeed1.ip.tiscali.net!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutp
eer01.lnd.ops.eu.uu.net!lnewsinpeer01.lnd.ops.eu.uu.net!bnewsoutpeer01.bru.o
ps.eu.uu.net!bnewsinpeer00.bru.ops.eu.uu.net!bnewspost00.bru.ops.eu.uu.net!e
mea.uu.net!not-for-mail
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.inetsdk.programming.wininet:11940
| X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
|
| Hi,
|
| I've read that
| INTERNET_OPTION_CONNECT_TIMEOUT
|
| never used to work but does now, however I can't get it functioning. I've
| downloaded and compiled the MS TEAR example
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/
html/_sample_mfc_tear.asp
|
| and added
|
| BOOL bret=session.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,0);
|
| after AfxParseURL (line 212).
|
|
|
| Would someone confirm whether it works and if so please post some code
| amendments to confirm that
| I can get it working on my machine?
|
| I have 6.0.2800.1405 of wininet.dll
|
| Thanks
|
|
|
|
|
|
|
|
Joe
2005-01-02 14:23:24 UTC
Permalink
"Brian Combs" <***@online.microsoft.com> wrote in message news:a%***@cpmsftngxa10.phx.gbl...

Hi Brian.
Post by Brian Combs
Hello
The answer is yes and no.
176420 BUG: InternetSetOption Does Not Set Timeout Values
http://support.microsoft.com/?id=176420
For IE 6.x the different timeout settings should be all fixed for HTTP
Yes, as I said I have 6.0.2800.1405 of wininet.dll installed iexplorer
6.0.2800.1106
Post by Brian Combs
however FTP may still fail. Also be aware that this is only connnect
timeout and you should also set the other timeout settings.
INTERNET_OPTION_CONNECT_TIMEOUT
INTERNET_OPTION_RECEIVE_TIMEOUT
INTERNET_OPTION_SEND_TIMEOUT
Yes, thanks for that, I hadn't added these other two timeouts.
Sometimes it seems to work, othertimes not (I don't *think* its down to the
server response) and I can't effect the INTERNET_OPTION_CONNECT_TIMEOUT
default value - it times out after just over 20 secs regardless of any value
I set.
Post by Brian Combs
I also don't know if MFC is doing anything that is keeping from being set
correctly. You can use debug build of WinInet to get a trace and see what
is happeing.,
884931 How to use the debug version of the Wininet.dll file for Internet
http://support.microsoft.com/?id=884931
OK I'll try and decipher it, but as a shortcut, would you post or direct me
to any code - as rudimentary as you like that actually *does* enact all the
timeouts (pref C/C++)?

Also, how can I set up a harness to test the INTERNET_OPTION_RECEIVE_TIMEOUT
and INTERNET_OPTION_SEND_TIMEOUT timeout options?

Its easy to test the INTERNET_OPTION_CONNECT_TIMEOUT as I just point to a
site thats down, but I can't work out how to simulate slows responses for
send and receive.

TIA
Joe
2005-01-02 19:24:22 UTC
Permalink
Post by Brian Combs
Hello
The answer is yes and no.
176420 BUG: InternetSetOption Does Not Set Timeout Values
http://support.microsoft.com/?id=176420
For IE 6.x the different timeout settings should be all fixed for HTTP
however FTP may still fail. Also be aware that this is only connnect
timeout and you should also set the other timeout settings.
INTERNET_OPTION_CONNECT_TIMEOUT
INTERNET_OPTION_RECEIVE_TIMEOUT
INTERNET_OPTION_SEND_TIMEOUT
I also don't know if MFC is doing anything that is keeping from being set
correctly. You can use debug build of WinInet to get a trace and see what
is happeing.,
884931 How to use the debug version of the Wininet.dll file for Internet
http://support.microsoft.com/?id=884931
It doesn't provide any information on how to replace the wininet.dll with
the debug version.
I can't do so, as it is protected by Windows file protection and if I
reboot in safe mode I get a program is currently in use message.

Any ideas?

Thanks
Joe
2005-01-03 03:17:01 UTC
Permalink
Post by Joe
Post by Brian Combs
Hello
The answer is yes and no.
176420 BUG: InternetSetOption Does Not Set Timeout Values
http://support.microsoft.com/?id=176420
For IE 6.x the different timeout settings should be all fixed for HTTP
however FTP may still fail. Also be aware that this is only connnect
timeout and you should also set the other timeout settings.
INTERNET_OPTION_CONNECT_TIMEOUT
INTERNET_OPTION_RECEIVE_TIMEOUT
INTERNET_OPTION_SEND_TIMEOUT
I also don't know if MFC is doing anything that is keeping from being set
correctly. You can use debug build of WinInet to get a trace and see what
is happeing.,
884931 How to use the debug version of the Wininet.dll file for Internet
http://support.microsoft.com/?id=884931
It doesn't provide any information on how to replace the wininet.dll with
the debug version.
I can't do so, as it is protected by Windows file protection and if I
reboot in safe mode I get a program is currently in use message.
Any ideas?
Thanks
Also what will the debug trace tell me?

I have done a setoption with th enew timeout values, then a queryoption
which returns the correct value.

What else should I look for?

Thanks.
Stephen Sulzer
2005-01-03 10:28:16 UTC
Permalink
Brian,

Are you sure that the Connect timeout works fully in WinInet? I am very
doubtful. In particular, I am pretty sure that the Connect timeout does not
work for synchronous HTTP requests, including in IE6 SP1. Was it fixed for
XP SP2 perhaps? The bug with the Connect timeout is not in
InternetSetOption, but in the core WinInet HTTP stack.

Also, I doubt a WinInet debug log will help with this problem.

Joe: in your testing, do not use a value of zero for the Connect timeout
(just in case it gets reinterpreted as a "special" value, namely INFINITE).
Try a small non-zero value instead, like 5 (for 5 milliseconds).

Stephen
Post by Brian Combs
Hello
The answer is yes and no.
176420 BUG: InternetSetOption Does Not Set Timeout Values
http://support.microsoft.com/?id=176420
For IE 6.x the different timeout settings should be all fixed for HTTP
however FTP may still fail. Also be aware that this is only connnect
timeout and you should also set the other timeout settings.
INTERNET_OPTION_CONNECT_TIMEOUT
INTERNET_OPTION_RECEIVE_TIMEOUT
INTERNET_OPTION_SEND_TIMEOUT
I also don't know if MFC is doing anything that is keeping from being set
correctly. You can use debug build of WinInet to get a trace and see what
is happeing.,
884931 How to use the debug version of the Wininet.dll file for Internet
http://support.microsoft.com/?id=884931
Thanks
Brian [MSFT]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Newsgroups: microsoft.public.inetsdk.programming.wininet
| Subject: does INTERNET_OPTION_CONNECT_TIMEOUT work or not?
| Date: Tue, 28 Dec 2004 03:23:28 -0000
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| Lines: 32
| NNTP-Posting-Host: 81-86-229-91.dsl.pipex.com
| X-Trace: 1104204209 news-text.dial.pipex.com 19158 81.86.229.91:4157
cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!tornado.fastwebnet.it!tiscali!new
sfeed1.ip.tiscali.net!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutp
eer01.lnd.ops.eu.uu.net!lnewsinpeer01.lnd.ops.eu.uu.net!bnewsoutpeer01.bru.o
ps.eu.uu.net!bnewsinpeer00.bru.ops.eu.uu.net!bnewspost00.bru.ops.eu.uu.net!e
Post by Brian Combs
mea.uu.net!not-for-mail
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.inetsdk.programming.wininet:11940
| X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
|
| Hi,
|
| I've read that
| INTERNET_OPTION_CONNECT_TIMEOUT
|
| never used to work but does now, however I can't get it functioning. I've
| downloaded and compiled the MS TEAR example
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/
Post by Brian Combs
html/_sample_mfc_tear.asp
|
| and added
|
| BOOL bret=session.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,0);
|
| after AfxParseURL (line 212).
|
|
|
| Would someone confirm whether it works and if so please post some code
| amendments to confirm that
| I can get it working on my machine?
|
| I have 6.0.2800.1405 of wininet.dll
|
| Thanks
|
|
|
|
|
|
|
|
Joe
2005-01-03 11:12:52 UTC
Permalink
Post by Stephen Sulzer
Brian,
Are you sure that the Connect timeout works fully in WinInet? I am very
doubtful. In particular, I am pretty sure that the Connect timeout does not
work for synchronous HTTP requests, including in IE6 SP1. Was it fixed for
XP SP2 perhaps? The bug with the Connect timeout is not in
InternetSetOption, but in the core WinInet HTTP stack.
Also, I doubt a WinInet debug log will help with this problem.
Joe: in your testing, do not use a value of zero for the Connect timeout
(just in case it gets reinterpreted as a "special" value, namely INFINITE).
Try a small non-zero value instead, like 5 (for 5 milliseconds).
Stephen
Hi Stephen,

Well , I've tried basically everything.
I've removed the MFC. I've tried an InternetSetOption with 0, 10,100 etc
etc.
I've placed in on each and every HINTERNET handle etc etc ect.

Nothing works. It *always* times out after 20 seconds. I have been able to
get the other 2 timeouts working intermittently.
INTERNET_OPTION_RECEIVE_TIMEOUT & INTERNET_OPTION_SEND_TIMEOUT.

But how can I set up a scenario where I can connect but the request fails so
I can test them fully?

Interestingly, If I InternetQueryOption without making any adjustments it
returns 300000 (30 secs) yet the timeout is always after 20!!!!
So something else is at play.

Also, I have read that the cancelling thread MS fix,
http://support.microsoft.com/kb/224318/EN-US/ will cancell all threads
currently accessing the Internet - so this is not an option, and its dirty
anyway.

Does timeout processing work OK with asynchronous requests?

Looks like it may be the only option.

I've spend *ages* on this - and I have read posts indicating there has been
this same bug going back 5 or more years (hence the thread title).

If the bug is *still* there..........

I'm pretty pissed off to put it mildly!!!!!!!!

Cheers
Brian Combs
2005-01-04 23:10:25 UTC
Permalink
Hello
Based on Stephen's post I went and took a look at some old bug reports and
found he is correct. They never fixed INTERNET_OPTION_CONNECT_TIMEOUT as
the timeout is imposed by winsock layer.
They do appear to have fixed the
INTERNET_OPTION_RECEIVE_TIMEOUT
INTERNET_OPTION_SEND_TIMEOUT
for HTTP only.

How to set them is quit easy.
DWORD Timeout = 5000;
InternetSetOption(NULL,INTERNET_OPTION_RECEIVE_TIMEOUT , &Timeout,
sizeof(Timeout));

I don't know of any easy way to test INTERNET_OPTION_SEND_TIMEOUT as it
appers to deal with connection speed and\or throttling on the server side.
Docs state the following: Sets or retrieves an unsigned long integer value
that contains the time-out value to send a request. Units are in
milliseconds. If the send takes longer than this time-out value, the send
is canceled.

To test INTERNET_OPTION_RECEIVE_TIMEOUT is quite easy. Just create a simple
ISAPI or CGI app and call Sleep() API to make the app wait a set amout of
time before it sends back the response.

If you want to control the timeout in code you can always create a worker
thread to handle this.

224318 How To Control Connection Timeout Value by Creating Second Thread
http://support.microsoft.com/?id=224318

You can also use asynchronous WinInet and cancel the call at any time.
However MFC WinInet classes are not designed to be used with async WinInet.
For async you can close the handle and then trap for
INTERNET_STATUS_HANDLE_CLOSING in the callback function.

WinHttp log may not be helpful in this case but it can help if you want to
see what is happening in WinInet.DLL
The article does cover how to use it on OS with protected by Windows file
protection
From the KB:
For Microsoft Windows Millennium Edition or later Windows versions, follow
these steps: a. Start Windows Explorer, and then find the location where
Internet Explorer is installed on your computer. Typically this is either
the C:\Program Files\Internet Explorer folder or the C:\Program
Files\Plus!\Microsoft Internet folder.
b. If all file name extensions are visible, go to step 4. Otherwise, click
Folder Options on the Tools menu.
c. Click the View tab.
d. Click Show all files.
e. Click to clear the Hide extensions of known file types check box.
f. Close the Folder Options dialog box.
g. Click File, point to New, and then click Text Document. Name the file
"Iexplore.exe.local." If the icon for this new file remains as a Notepad
document, repeat step 3e.
h. Save a copy of the debug version of the Wininet.dll file in the
Internet Explorer folder.

If you are using a custom WinInet program, you can replace the name
"Iexplore" in "Iexplore.exe.local" with your program file name. After you
do this, run your program at a command prompt.

Windows 2000 and later Windows versions support the usage of the
Iexplore.exe.local file. This forces Internet Explorer to use just the DLLs
in the Internet Explorer folder.

Note: For custom WinInet Apps you just use the folder your app is in and
use your filename and not iexplore


Thanks
Brian [MSFT]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Joe" <***@home.com>
| Newsgroups: microsoft.public.inetsdk.programming.wininet
| References: <41d0d1b0$0$19158$***@news-text.dial.pipex.com>
<a#***@cpmsftngxa10.phx.gbl> <aPmdnVV66qffg0TcRVn-***@seanet.com>
| Subject: Re: does INTERNET_OPTION_CONNECT_TIMEOUT work or not?
| Date: Mon, 3 Jan 2005 11:12:52 -0000
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| Lines: 73
| Message-ID: <41d928b5$0$16588$***@news-text.dial.pipex.com>
| NNTP-Posting-Host: 81-86-223-49.dsl.pipex.com
| X-Trace: 1104750773 news-text.dial.pipex.com 16588 81.86.223.49:4267
| X-Complaints-To: ***@uk.uu.net
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.s
ul.t-online.de!t-online.de!news.zanker.org!feeder1.cambrium.nl!feed.tweaknew
s.nl!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams
.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!peer-uk
.news.demon.net!kibo.news.demon.net!demon!news.clara.net!wagner.news.clara.n
et!lnewsoutpeer00.lnd.ops.eu.uu.net!lnewsinpeer00.lnd.ops.eu.uu.net!bnewsout
peer00.bru.ops.eu.uu.net!bnewsinpeer01.bru.ops.eu.uu.net!bnewspost00.bru.ops
.eu.uu.net!emea.uu.net!not-for-mail
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.inetsdk.programming.wininet:11965
| X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
|
|
| "Stephen Sulzer" <sasulzer at seanet.com> wrote in message
| news:aPmdnVV66qffg0TcRVn-***@seanet.com...
| >
| > Brian,
| >
| > Are you sure that the Connect timeout works fully in WinInet? I am very
| > doubtful. In particular, I am pretty sure that the Connect timeout does
| not
| > work for synchronous HTTP requests, including in IE6 SP1. Was it fixed
for
| > XP SP2 perhaps? The bug with the Connect timeout is not in
| > InternetSetOption, but in the core WinInet HTTP stack.
| >
| > Also, I doubt a WinInet debug log will help with this problem.
| >
| > Joe: in your testing, do not use a value of zero for the Connect timeout
| > (just in case it gets reinterpreted as a "special" value, namely
| INFINITE).
| > Try a small non-zero value instead, like 5 (for 5 milliseconds).
| >
| > Stephen
| >
|
|
| Hi Stephen,
|
| Well , I've tried basically everything.
| I've removed the MFC. I've tried an InternetSetOption with 0, 10,100 etc
| etc.
| I've placed in on each and every HINTERNET handle etc etc ect.
|
| Nothing works. It *always* times out after 20 seconds. I have been able to
| get the other 2 timeouts working intermittently.
| INTERNET_OPTION_RECEIVE_TIMEOUT & INTERNET_OPTION_SEND_TIMEOUT.
|
| But how can I set up a scenario where I can connect but the request fails
so
| I can test them fully?
|
| Interestingly, If I InternetQueryOption without making any adjustments it
| returns 300000 (30 secs) yet the timeout is always after 20!!!!
| So something else is at play.
|
| Also, I have read that the cancelling thread MS fix,
| http://support.microsoft.com/kb/224318/EN-US/ will cancell all threads
| currently accessing the Internet - so this is not an option, and its dirty
| anyway.
|
| Does timeout processing work OK with asynchronous requests?
|
| Looks like it may be the only option.
|
| I've spend *ages* on this - and I have read posts indicating there has
been
| this same bug going back 5 or more years (hence the thread title).
|
| If the bug is *still* there..........
|
| I'm pretty pissed off to put it mildly!!!!!!!!
|
| Cheers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Joe
2005-01-05 04:25:15 UTC
Permalink
Post by Brian Combs
Hello
Based on Stephen's post I went and took a look at some old bug reports and
found he is correct. They never fixed INTERNET_OPTION_CONNECT_TIMEOUT as
the timeout is imposed by winsock layer.
Hmmpffhh!!

Thanks anyway.

Loading...