Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Threads hanging in WinInet

383 views
Skip to first unread message

Steve Draper

unread,
Aug 17, 2000, 3:00:00 AM8/17/00
to
I am experiencing problems with calls to HttpSendRequest() hanging up in
WinInet for long timeout periods (approx 10 minutes) with no apparent
way to shorten this. The behaviour occurs when packets are dropped (and
is thus a reasonable default behaviour). However there are several
things I should be able to do about it:

1) Change the timeout. However there is known bug in some versions of
WinInet that means that this doesn't always work. The recommended
workaround is to use async mode, which brings us to...

2) Use async mode. Unfortunately I cannot get HttpSendRequestEx() to
work in async mode at all! (InternetOpenUrl() works fine but isn't rich
enough for my needs). HttpSendRequestEx() used on a handle that was
opened in async mode (inherrited from one returned from InternetOpen()
with the ASYNC flag) always returns ERROR_IO_PENDING (and doesn't kick
off a send - the callback is not called and a socket-level trace shows
no acivity). This is similar to another known bug with async use of one
of the FTP functions, the recommended workaround to which is...

3) Use another thread to monitor elapsed time and terminate the first
request on the original thread using InternetCloseHandle() when it
decides it should be timed out. In none-problem states this seems to
work fine, but in my original problem state closing the handle does NOT
unblock the original HttpSendRequest() call! This eventually returns
after 10 minutes but the closing of its handle doesn't expedite this!!!

At this point I'm out of options and ideas. If anyone has seen this
behaviour and has any ideas/workarounds please let me know (I'd
appreciate an email if possible - steve_...@iora.com)


Anatoliy Savchak

unread,
Aug 17, 2000, 3:00:00 AM8/17/00
to

Do you understand, that calling some function like HttpSendRequest with
ASYNC mode do not allways return a value. They, just start working in
background, BUT, they do not stop your process. You must stop your
rocess( thread) and wait until BG work will be done.
Anatoliy Savchak

"Steve Draper" <steve_...@iora.com> wrote in message
news:38F675F48B36D4118E4D...@cpmsftmsgv21.microsoft.com...

Anatoliy Savchak

unread,
Aug 17, 2000, 3:00:00 AM8/17/00
to

Such error can be solved by:
1) Create your structure, that includes smth like "Event"
2) Create callback function and set immidiatly after InternetOpen()
calls.
3) after calling HttpSendRequest(..., DWORD(@yourstructure)) look to
GetLastError(). If it is ERROR_IO_PENDING then everything is ok and you
have to wait until that "process" ends: assign Event,
Event.WaitFor(INFINITE). And in Callback function Set Event.
Got it?
Anatoliy Savchak


Elton John - ok not really

unread,
Aug 17, 2000, 3:00:00 AM8/17/00
to
The bug with timeout and SendRequest was fixed with IE 5.01's wininet.dll.

Also, I learned that sendrequest will hang if you accidentally use the wrong
port number. Such as accidentally using the SSL port 443 for a regular
request that should have been on port 80.

deisen...@operamail.com

unread,
Aug 17, 2000, 3:00:00 AM8/17/00
to
In article
<38F675F48B36D4118E4D...@cpmsftmsgv21.microsoft.com>,

Anatoliy Savchak <SA...@eleks.lviv.ua> wrote:
>
> Such error can be solved by:
> 1) Create your structure, that includes smth like "Event"
> 2) Create callback function and set immidiatly after InternetOpen()
> calls.
> 3) after calling HttpSendRequest(..., DWORD(@yourstructure)) look to

Does HttpSendRequestEx have to be followed by HttpEndRequest to
actually send the request? Is InternetWriteFile necessary?

What should the 4th parameter of HttpSendRequestEx be in asynchronous
mode?

My callback function receives INTERNET_STATUS_REQUEST_COMPLETE before
INTERNET_STATUS_REQUEST_SENT or INTERNET_STATUS_REQUEST_RECEIVED, any
suggestions why?

Sorry for all the questions, this has been much trouble for me.

thanks,
Darren

> GetLastError(). If it is ERROR_IO_PENDING then everything is ok and
you
> have to wait until that "process" ends: assign Event,
> Event.WaitFor(INFINITE). And in Callback function Set Event.
> Got it?
> Anatoliy Savchak
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.

Steve Draper

unread,
Aug 21, 2000, 3:00:00 AM8/21/00
to

I am not seeing the behaviour alluded to in the response posts so far on
this thread. My callback is NEVER called after the call for handle
creation (which is). The structure I have (as a test only!) is for the
main thread (which issued the async send) to simply sit in a polling
loop (issuing Slep(1000) calls) until the callback signals send
completion (which never happens as it is never called!)


deisen...@operamail.com

unread,
Aug 22, 2000, 3:00:00 AM8/22/00
to
In article
<38F675F48B36D4118E4D...@cpmsftmsgv21.microsoft.com>,


Steve,

I have been attempting to issue asynchronous https Wininet requests for
the last week with inconsistent success. Which handle are you passing
to InternetSetStatusCallback? Are you specifying your callback
function's context value as the last parameter to the InternetConnect
and HttpOpenRequest functions? I have found that synchronizing your
main thread with the callback function works well with CreateEvent,
ResetEvent, WaitForSingleObject, and SetEvent.

hope this helps,
Darren

Alexandre Folle de Menezes

unread,
Aug 23, 2000, 3:00:00 AM8/23/00
to

> Does HttpSendRequestEx have to be followed by HttpEndRequest to
> actually send the request?
Yes.

>Is InternetWriteFile necessary?
No, unless you actually want to send data.

> What should the 4th parameter of HttpSendRequestEx be in asynchronous
> mode?

HSR_ASYNC

> My callback function receives INTERNET_STATUS_REQUEST_COMPLETE before
> INTERNET_STATUS_REQUEST_SENT or INTERNET_STATUS_REQUEST_RECEIVED,
> any suggestions why?

There is no INTERNET_STATUS_REQUEST_RECEIVED. Do you mean
INTERNET_STATUS_RESPONSE_RECEIVED? Anyway, I don't know why.

Alexandre de Menezes.

deisen...@operamail.com

unread,
Aug 24, 2000, 3:00:00 AM8/24/00
to
In article <eY$kKfRDAHA.243@cppssbbsa04>,

"Alexandre Folle de Menezes" <nospam@here> wrote:
>
> > Does HttpSendRequestEx have to be followed by HttpEndRequest to
> > actually send the request?
> Yes.
>
> >Is InternetWriteFile necessary?
> No, unless you actually want to send data.


Actually, I've now implemented this successfully without calling
InternetWriteFile. I fill the INTERNET_BUFFERS structure with my data
and pass it to HttpSendRequestEx.


>
> > What should the 4th parameter of HttpSendRequestEx be in
asynchronous
> > mode?
> HSR_ASYNC
>
> > My callback function receives INTERNET_STATUS_REQUEST_COMPLETE
before
> > INTERNET_STATUS_REQUEST_SENT or INTERNET_STATUS_REQUEST_RECEIVED,
> > any suggestions why?
> There is no INTERNET_STATUS_REQUEST_RECEIVED. Do you mean
> INTERNET_STATUS_RESPONSE_RECEIVED?


Yes, sorry my fault.


Anyway, I don't know why.
>
> Alexandre de Menezes.
>
>


Your help is very much appreciated Alexandre.

Darren Eisenzimmer

0 new messages