473,398 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

WebClient Freezes for Ten Seconds on First Connect

I've build a client-server application in which the client communicates with
the server by making calls to WebClient.UploadValuesAsync().

In a given client session, hundreds of calls will be made and generally
speaking I'm pleased with the performance. It only takes a few milliseconds
from the time UploadValuesAsync() is called to the time the server receives
the request and begins processing it. The problem is that the FIRST call of
the session takes around ten seconds to get from client to server.

During this ten second period, the UploadValuesAsync() call blocks.
Repeatedly running "netstat -n" at the command line indicates that the
connection is not established during this period. Then, after ten sesconds,
netstat shows the new connection, UploadValuesAsync() unblocks, and all is
well.

I can't for the life of me figure out what is causing this problem. The ten
second hang time wouldn't really bother me in production mode, but it makes
development a real pain, because each time I make a change to the code and
want to test it, I have to deal with it. Any ideas?

Jules
Apr 9 '08 #1
1 1813
Here's the solution for anyone who is interested:

WebClient internally makes use of HttpWebRequest. HttpWebRequest exposes a
property called Proxy which for some reason is, by default, set to a
non-null value. This is despite the fact that I do NOT USE A PROXY, nor is
Internet Explorer configured to use one.

Anyway, the fact that this Proxy property is non-null is not problematic in
most cases. My case is somewhat unusual, however, in that my development
machine is connected via PPTP VPN to a remote network. Now, this shouldn't
really matter since the server to which my app is connecting isn't on the
other side of the VPN. The VPN isn't involved in the client-server
transaction at ALL, but I noticed that when the VPN was disconnected, the
ten second delay mentioned in my original post went away. Weird! It turns
out that by manually setting the Proxy property to null on the WebClient
(which in turn sets the Proxy property to null on the underlying
HttpWebRequest), the problem is resolved. When the Proxy property is set to
null, the delay goes away, regardless of whether or not the VPN is
connected.

Hopefully this will help someone else that runs into this bizarre bug.

Jules

Apr 9 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sven Putze | last post by:
my target: I want to upload a file via HTTP Post and show the user a progress bar my 1st try: I´ve used WebClient.UploadFile and WebClient.UploadData, they work fine but I don't know any...
1
by: yyy | last post by:
This problem bothers me for a long time: I use WebClient.DownloadData in order to read text from an HTML document this way: WebClient c = new WebClient(); string html=...
0
by: Kumar | last post by:
Hi all, I have the following code which uses WebClient.UploadValues myNameValueCollection.Add("Name", name) myNameValueCollection.Add("Age", age) .............. ............. Dim web As New...
3
by: ddd | last post by:
Hi, I am trying to use webclient to download a file from a windows application and I notice that the application freezes while the file downloads. The file is about 300k so it takes a few...
0
by: Jarod_24 | last post by:
I have some problems with using Net.WebClient This function of mine recieves an array with Urls, and Filenames, and is supposed to download all the files (binary files) that is listed in the...
4
by: genojoe | last post by:
My development computer (1 gig, XP Home Edition SP2) freezes when I am editing a very large VB.NET project. It can take minutes to move between a code pane and the Find and Replace pane. On...
0
by: Marcin Szarek | last post by:
Hi! For a few months we suffer mysterious problem with Oracle 10g RAC (more details on server configuration at the bottom). At regular basis (every 5 minutes) nodes of our cluster "freeze" -...
1
by: Mad Scientist Jr | last post by:
For some reason I can't get a WebClient to access an outside URL from behind our firewall. The code works when it runs outside the firewall. I turned on windows authentication in the web.config...
1
by: Macneed | last post by:
i am a newbie, i want to write a code to download data from web using webclient string HTMLstring = ""; WebClient client = new WebClient(); Byte HP =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.