471,595 Members | 2,043 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

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

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

Nov 1 '06 #1
5 4675
Thus wrote mr*************@gmail.com,
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,
--
Joerg Jooss
ne********@joergjooss.de
Nov 2 '06 #2
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

Joerg Jooss wrote:
Thus wrote mr*************@gmail.com,
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,
--
Joerg Jooss
ne********@joergjooss.de
Nov 2 '06 #3
Thus wrote mr*************@gmail.com,
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,
--
Joerg Jooss
ne********@joergjooss.de
Nov 3 '06 #4
Sorry, but what do you mean by AD?

Thanks,
Scott

Joerg Jooss wrote:
Thus wrote mr*************@gmail.com,
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,
--
Joerg Jooss
ne********@joergjooss.de
Nov 6 '06 #5
Thus wrote mr*************@gmail.com,
Sorry, but what do you mean by AD?
Active Directory.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Nov 6 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Maris Janis Vasilevskis | last post: by
reply views Thread by msnews.microsoft.com | last post: by
2 posts views Thread by wajih.boukaram | last post: by
1 post views Thread by ALA | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.