Trying here since no answer in the others grps]
Hello all:
I am building an intranet application for use with our company's call center
that allows operators in the call center the ability to communicate with one
another, exchange files, images, etc... via the corp intranet. Very similiar
to a standard chat program, the difference being that this app will
eventually hook into our proprietary call center software (but not yet
fortunately).
I have a server that is very robust and, when I contact it from a Win32 app
using sockets, the performance is excellent. However, this is only in
testing. For production, we need to have a web-based solution. Originally,
this was written in Java using applets and worked fine, but corporate has
standardized all 'new' development on the .NET platform so this is no longer
an option.
Situation: I wrote an example Forms UserControl, hosted it in IE (yes, I
did adjust all the permissions, code grp issues, etc... to get it working)
on a test html page that opens an asynchronous socket connection to the
server. The connection works fine once the 'connect' callback method is
called. It's just that this callback takes around a minute 45 seconds to
callback. Once it calls back, there is no trouble. Send and Receive
callbacks fire quickly... it's just this initial connect callback that is
taking so long. Meanwhile the connection is accepted by the listening socket on the server almost instantly. I have not tried using a packet sniffer yet and am trying to avoid that but will do so if no one has any ideas. Some sample code below (though none of it should surprise you - standard callback):
private void btnConnect_Click(object sender, System.EventArgs e)
{
try
{
IPHostEntry ipHostInfo = Dns.Resolve(ip);
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint localEP = new IPEndPoint(ipAddress, port);
client = new Socket(AddressFamily.InterNetwork,SocketType.Stream,
ProtocolType.Tcp);
connectDone.Reset();
client.BeginConnect(localEP,new AsyncCallback(ConnectCallback), client);
rtbChatMsg.Invoke(new DelWriteMsg(writeMsg),new object[]{"Connecting to
server..."});
connectDone.WaitOne();
}
catch (Exception ex)
{
rtbChatMsg.Invoke(new DelWriteMsg(writeMsg),new object[]{ex.ToString()});
}
}
//And the callback looks like
private void ConnectCallback(IAsyncResult ar)
{
try
{
// Retrieve the socket from the state object.
Socket client = (Socket) ar.AsyncState;
// Complete the connection.
client.EndConnect(ar);
// Signal that the connection has been made.
connectDone.Set();
rtbChatMsg.Invoke(new DelWriteMsg(writeMsg),new object[]{"Connected!"});
}
catch (Exception ex)
{
rtbChatMsg.Invoke(new DelWriteMsg(writeMsg),new object[]{ex.ToString()});
}
}
Anyone have any ideas why this is taking so long on the initial connection
Thanks All,
Alex

UserControl in IE taking a long time with Async Events
TimGL
"From my research it seems that it is a known issue. It appears that the code is blocking on getting the .config file during TcpClient.connect. There is a lock lower in the stack that we hit again when creating a new connection to get the config file.
Can you please try the following to workaround the problem :
Add the following line before socket instantiation (before the socket class usage)
int tmp = ServicePointManager.DefaultConnectionLimit
This line will force the loading of the config files. Let me know whether it helps...."
After I tried their workaround, the connection works without any issues.
Alex