We just upgraded to .NET 1.1 last week, and while being
pleased to see most of the code run flawlessly, we ran
into what we could only describe a bug (new feature ?) in
this version of .NET.
In a page we host a client control that connects to a
server (standard WinForm application) using sockets. In
1.0, no problem at all, but when we tested with 1.1, IE
froze and did not answer any UI call with the mouse or
the keyboard.
We did some further testing, and found out that the
client was stuck while calling Connect(), while the
server was already ready to receive (Accept was finished
at that time).
Add to this the fact that the exact same DLL, when used
as a custom control in a windows form application, ran
without any problem - this made us test things a bit more
thoroughly, and the results are below. All results come
from code compiled with VS2003. IE version : 6.0, SP1.
- Hosted Control in IE
(synchronous/asynchronous client and server code was
downloaded from the MSDN samples)
(Security settings put to Full Trust for the zone ;
setting them to Socket->All Access yielded the same
results)
Client Server
Synchronous Synchronous -> Freeze(1)
Synchronous Asynchronous -> Freeze(1)
Asynchronous Synchronous -> Freeze(2)
Asynchronous Asynchronous -> Freeze(1)
Description of the symptoms :
(1):This was in fact not a complete freeze. The first
Connect call for the client takes between 100 and 103
seconds each time (we tested this around 40 times). Once
this Connect call is done with, sending and receiving are
as quick as usual, that is they seem instant to a user.
100 seconds seems very strange as a value ... is there
some kind of timeout ?
More importantly, the next time Connect is called, it is
also done instantly.
Finally, even if the server is shutdown and then
restarted, the client Connect also finishes instantly.
HOWEVER, if IE is closed and then restarted, the next
Connect call will take 100 seconds to accomplish -> IE
loading problem ?
(2):This was a bit stranger than (1). Globally it's the
same pattern, except in one case - when you restart IE
and not the server. In that case, the next client call to
Connect will not take 100 seconds - it will really freeze
(we waited more than one hour unsuccessfully). This might
be an error on our side, since the same problem occured
with the Windows Forms host tests (see below), but it
still sounds strange enough to warrant being put in.
- Windows Forms hosted client control for comparison sake
(same DLL as in the previous tests)
Client Server
Synchronous Synchronous -> NTD
Synchronous Asynchronous -> NTD
Asynchronous Synchronous -> NTD(1)
Asynchronous Asynchronous -> NTD
(1):As we said just earlier, while this case, like the 3
others, shows no latency in connecting the first time, if
the application is closed and then restarted while the
server stays up, the next Connect call will freeze the
application.
Other facts :
- As I said before, if I host in IE the same DLL as
before but in its 1.0 version and with a version 1.0
Framework, it works without problems. HOWEVER, the same
version 1.0 DLL, when hosted in IE with the 1.1
Framework, does NOT work and freezes like the previous
samples.
From the test results, it would seem that that the first
time Connect (or any Socket call ? I could only test
Connect) is called after IE/the DLL is loaded, there is a
huge lap of time during which the client stops responding
(what happens at that moment ?). Once the call returns,
things go on normally like they did in 1.0 or in a
windows form application. Is this some sort of
initialization of IE/the DLL ?
As you can imagine this makes the page we develop
completely unuseable, which is one of the main components
of our system ... Is there - hopefully - something we
missed ? Is this an already documented bug for which a
fix has been found ? Or is this new ? If it's a not yet
documented bug, how could it be ported to Microsoft
attention ?
Thank you in advance to anyone who could give even a bit
of help on the subject ; we can't downgrade to 1.0, and
we're beginning to get stuck on this problem ...
I looked at the newsgroup archives for the last 3 months,
I could only find one thread concerning the subject, and
no response about it - here is the thread :
*****************************************
Subject: Sockets question
Sent: 6/10/2003 1:33:32 PM
I should mention it works fine when I use the dll in
a .net exe, but it blows up when I use it in Internet
Explorer.
>-----Original Message-----
>Why would the method SetToConnected() hang when I am
>trying to connect a socket to a remote server from
a .NET
>Class Library (dll) using mySocket.Connect
(remoteEndPoint)?