First call to HttpWebRequest.GetResponse() takes forever and fails, after that it works?

  • Thread starter mr.newsgroupguy
  • Start date
M

mr.newsgroupguy

I am working in C# .NET 1.1. My app has a button on its main form that
checks to see if it has access to a file on our server, just an XML
file. On our server we are running W2K IIS with a virtual directory,
set to Windows Authentication. I am creating an HTTPWebRequest object
on the client, and setting its Credentials to
CredentialCache.DefaultCredentials. Also, I have tried numerous
Timeout settings, but they have not made a difference.

When I run the app on a client that is connected to our internal
network, everything works great. When I try and run through a client
that is connected through the Internet, and come in through a secure
tunnel, it takes forever and then fails the first time, but if we try
again without closing the app, it works every time there after.

Now, first off I have noticed while tracing the port that the call to
GetResponse() first returns a 401 error, but then it authenticates and
goes through, the same from both clients. I have noticed in the forums
that people have mentioned that GetResponse() actually may get a 401
error first so that the client can then send authentication.

When I use IE to access the URL to this file from the client on the
Internet, it works the first time and is fast.

What I have had to do to remedy the situation for now is test the
return value I get from my first check, and if it fails, I repeat it.
It still has the time delay but it ends up connecting without making
the user click twice.

What is wrong with GetResponse()? What else can I try to change to
have it connect the first time?

Thanks in advance,
Scott
 
J

Joerg Jooss

Thus wrote (e-mail address removed),
I am working in C# .NET 1.1. My app has a button on its main form
that checks to see if it has access to a file on our server, just an
XML file. On our server we are running W2K IIS with a virtual
directory, set to Windows Authentication. I am creating an
HTTPWebRequest object on the client, and setting its Credentials to
CredentialCache.DefaultCredentials. Also, I have tried numerous
Timeout settings, but they have not made a difference.

When I run the app on a client that is connected to our internal
network, everything works great. When I try and run through a client
that is connected through the Internet, and come in through a secure
tunnel, it takes forever and then fails the first time, but if we try
again without closing the app, it works every time there after.

I would check this behaviour using a network sniffer like Wireshark.
Now, first off I have noticed while tracing the port that the call to
GetResponse() first returns a 401 error, but then it authenticates and
goes through, the same from both clients. I have noticed in the
forums that people have mentioned that GetResponse() actually may get
a 401 error first so that the client can then send authentication.

That's how HTTP authentication works and not specific to HttpWebRequest.
When I use IE to access the URL to this file from the client on the
Internet, it works the first time and is fast.

What I have had to do to remedy the situation for now is test the
return value I get from my first check, and if it fails, I repeat it.
It still has the time delay but it ends up connecting without making
the user click twice.

What is wrong with GetResponse()? What else can I try to change to
have it connect the first time?

You can save all but the first challenge/response exchanges if you set HttpWebRequest.PreAuthenticate
to true.

Cheers,
 
M

mr.newsgroupguy

Well I want to have the network people here tell me exactly were my
connection is stopping. They are trying to tell me that it is my
application, not the network but the have yet to provide me with the
details.. I think they are full of it considering that I am doing one
of the simplest things you can with HTTP, a GetResponse(). They put a
sniffer on it and the first attempt by the client never reaches my
server, but the subsequent ones do. I wonder if this could be a
problem with our switches?

Thanks
 
J

Joerg Jooss

Thus wrote (e-mail address removed),
Well I want to have the network people here tell me exactly were my
connection is stopping. They are trying to tell me that it is my
application, not the network but the have yet to provide me with the
details.. I think they are full of it considering that I am doing one
of the simplest things you can with HTTP, a GetResponse(). They put a
sniffer on it and the first attempt by the client never reaches my
server, but the subsequent ones do. I wonder if this could be a
problem with our switches?

Well, it is probably related to the fact that you're using a VPN connection
-- maybe you're waiting to get authenticated by your AD?

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top