Discussion:
InternetReadFile hangs indefinitely
(too old to reply)
Yannick Turgeon
2006-01-13 22:16:36 UTC
Permalink
Hello all,

To make a very long story short when I call function InternetReadFile,
it hangs and never return (not in less than 25 minutes thought).

BUT, my situation is a bit special I think. We are currently using
vbXMLRPC.dll in a client (say "ClientA") to communicate with a python
home-made server application (say "ServerA"). It works great. Now, I
have to build another VB application (say "ClientB") to communicate
with another python home-made server (say "ServerB") using vbXMLRPC.dll
too. But ServerB uses SSL. vbXMLRPC.dll actually has this feature.

Here is some facts concerning my situation:
- ServerA (HTTP) works fine with ClientA (vbXMLRPC.dll).
- ServerA (HTTP) works fine too with a PHP client (PHP XML-RPC module).
- ServerB (HTTPS) works fine with a python client (python xmlrpclib).
- ServerB (HTTPS) hangs forever with ClientB (vbXMLRPC.dll).
- Both server use XML-RPC protocol.
- ServerA runs on a W2K server.
- ServerB runs on a Linux server.

I've found on the net some code to test the wininet.dll used by
vbXMLRPC.dll. It appears that I've got the same problem using the
wininet.dll directly (bypassing vbXMLRPC.dll). (full code I used can be
viewed here: http://docvb.free.fr/apidetail.php?idapi=208 (see exemple
near middle of the page)).
The part where it hangs is:
-------------------------------------
Do While blDoLoop
stRead = vbNullString
blDoLoop = InternetReadFile(hRequest, stRead, Len(stRead),
lgRead) ' <--- *** here ***
stLoad = stLoad & Left$(stRead, lgRead)
If Not CBool(lgRead) Then blDoLoop = False
Loop
-------------------------------------

What else? Humm... Oh, I tried to contact the ServerB using IE, Firefox
(calling a page page which returne a 501 error as expected) and
ClientB: All three hang, never reaching the EOF but Firefox prints what
it received: the 501 web page. IE and ClientB don't... till I kill
ServerB.

Looking at ServerB log, I can see that the SSL negotiation is correctly
done. Then the server send the answer (501 error)... and hangs on its
side too. So both server and client are hanging. I kill the server: the
client returns the output. It looks like the socket is nerver closed.

Client CPU is not active so it's not related to KB263754 (
http://support.microsoft.com/?scid=kb%3Ben-us%3B263754&x=10&y=9 ).
Anyway, I tried the proposed solution without success.

So, my question is: Anybody know the reason, has a solution to solve
this problem?

Thanks a lot for your time.

Yannick
Scherbina Vladimir
2006-01-14 14:59:21 UTC
Permalink
Post by Yannick Turgeon
Hello all,
To make a very long story short when I call function InternetReadFile,
it hangs and never return (not in less than 25 minutes thought).
BUT, my situation is a bit special I think. We are currently using
vbXMLRPC.dll in a client (say "ClientA") to communicate with a python
home-made server application (say "ServerA"). It works great. Now, I
have to build another VB application (say "ClientB") to communicate
with another python home-made server (say "ServerB") using vbXMLRPC.dll
too. But ServerB uses SSL. vbXMLRPC.dll actually has this feature.
- ServerA (HTTP) works fine with ClientA (vbXMLRPC.dll).
- ServerA (HTTP) works fine too with a PHP client (PHP XML-RPC module).
- ServerB (HTTPS) works fine with a python client (python xmlrpclib).
- ServerB (HTTPS) hangs forever with ClientB (vbXMLRPC.dll).
- Both server use XML-RPC protocol.
- ServerA runs on a W2K server.
- ServerB runs on a Linux server.
I've found on the net some code to test the wininet.dll used by
vbXMLRPC.dll. It appears that I've got the same problem using the
wininet.dll directly (bypassing vbXMLRPC.dll). (full code I used can be
viewed here: http://docvb.free.fr/apidetail.php?idapi=208 (see exemple
near middle of the page)).
-------------------------------------
Do While blDoLoop
stRead = vbNullString
blDoLoop = InternetReadFile(hRequest, stRead, Len(stRead),
lgRead) ' <--- *** here ***
stLoad = stLoad & Left$(stRead, lgRead)
If Not CBool(lgRead) Then blDoLoop = False
Loop
-------------------------------------
What else? Humm... Oh, I tried to contact the ServerB using IE, Firefox
(calling a page page which returne a 501 error as expected) and
ClientB: All three hang, never reaching the EOF but Firefox prints what
it received: the 501 web page. IE and ClientB don't... till I kill
ServerB.
Looking at ServerB log, I can see that the SSL negotiation is correctly
done. Then the server send the answer (501 error)... and hangs on its
side too. So both server and client are hanging. I kill the server: the
client returns the output. It looks like the socket is nerver closed.
Client CPU is not active so it's not related to KB263754 (
http://support.microsoft.com/?scid=kb%3Ben-us%3B263754&x=10&y=9 ).
Anyway, I tried the proposed solution without success.
So, my question is: Anybody know the reason, has a solution to solve
this problem?
Thanks a lot for your time.
Yannick
Have you tried to watch what is passing to/from server using sniffer (IRIS
is good for this) ? That might be the problem of your server, so tracking
all negotiations between client / server might shed light on your problem.

--
Vladimir
Yannick Turgeon
2006-01-18 20:55:38 UTC
Permalink
Hello Vladimir,

Since it's SSL, sniffer are not very usefull, aren't they?

But you make me think to output everything juste before encryption and
after decryption server-side. I finally found both the reason and the
solution.

The reason came from the fact that the code I took from the web to use
XMLRPC with SSL was build on the premisse that the request header and
the request data are both sent in different socket send batch, one
after the other. Python xmlrpclib is doing that but not vbXMLRPC.dll: a
single data bunch is sent. So the server was waiting for the client to
send another data bunch. I hacked the code that I took on the web to
handle both situations. It's no more freezing now.

Thanks for your time.

Yannick
Scherbina Vladimir
2006-01-18 21:00:46 UTC
Permalink
Things always become clear when you're begining to investigate how composite
mechanism works in details.
--
Vladimir
Post by Yannick Turgeon
Hello Vladimir,
Since it's SSL, sniffer are not very usefull, aren't they?
But you make me think to output everything juste before encryption and
after decryption server-side. I finally found both the reason and the
solution.
The reason came from the fact that the code I took from the web to use
XMLRPC with SSL was build on the premisse that the request header and
the request data are both sent in different socket send batch, one
after the other. Python xmlrpclib is doing that but not vbXMLRPC.dll: a
single data bunch is sent. So the server was waiting for the client to
send another data bunch. I hacked the code that I took on the web to
handle both situations. It's no more freezing now.
Thanks for your time.
Yannick
Loading...