473,473 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

error receiving information from fixed IP address "The underlying connection was closed: An unexpected error occurred on a receive."

I'm trying to connect to a fixed IP address (eg. http://10.60.903.50/TempFile) in order to retrieve one accii line of text in TempFile.

I try to read the information with this code:
string fullpath = " http://10.60.93.51/TempFile ";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(fullpath);
//req.KeepAlive = false;
HttpWebResponse res;
StreamReader sr;
string strResult = "";

res = (HttpWebResponse) req.GetResponse(); // <--- this line brings the error
sr = new StreamReader(res.GetResponseStream(), Encoding.ASCII);
txt_compTemp.Text = sr.ToString();
In the GetRespones, I get the error: "The underlying connection was closed: An unexpected error occurred on a receive. ". I read in an article that a possible solution would be to make the KeepAlive property of HttpWebRequest to False. It kept on giving me the error (That's why it's commented).

What else should I try?

Thank you,
Angel

Nov 15 '05 #1
1 2938

Hi Angel,

Thank you for using MSDN Newsgroup! My name is Jeffrey, and I will be
assisting you on this issue.
Based on my understanding, when you using HttpWebResponse.GetResponse
method to receive data, "The underlying connection was closed: An
unexpected error occurred on a receive. " error generated.

=======================================
Based on my experience, the problem may due to network issue. Perhaps you
are using a proxy server? If so, you'd have to create a WebProxy object
and use the Proxy property on the HttpWebRequest to set the proxy.
Also, your proxy may need credential to access, you can specify the
credential through NetworkCredential class. Normally, if you want to use
credentials of the currently
logged in user, you can refer to CredentialCache.DefaultCredentials instead
of specifying the password and username explicitly.

There is a sample in the WebRequest.Proxy Property document below:
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemNetWebRequestClassProxyTopic.asp

For how to use current logged user credentail, please refer to:
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemnetcredentialcacheclassdefaultcredentia lstopic.asp

=======================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #2

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

Similar topics

1
by: Leonard Danao | last post by:
I get this error when i run my code below "An unhandled exception of type 'System.Net.WebException' occurred in system.dll Additional information: The remote server returned an error: (401)...
4
by: Sagaert Johan | last post by:
i get this error if i write this : using System.Net.Sockets; .... .... TcpClient tcp; tcp=new TcpClient();
2
by: TheBurgerMan | last post by:
Hi all. I am using W2K3, .NET2 on a machine running AD and Exchange. I started getting the message below last week. I googled the error and not much was returned, but I did find this;...
4
by: Earl | last post by:
To upgrade or not? This, to me, is based upon whether or not Microsoft has -- at least -- fixed the buggy controls from VS2003: Combo (clearing and binding context issues) Checked ListBox...
7
by: Kath | last post by:
Hi, I hope this is the most relevant newsgroup for this post. I have a VB.NET app that uses the MapPoint component, and in my app I use pushpins to display/retrieve GPS locations....
2
by: tharu80 | last post by:
Hi,Im in final year student. my graduation project is making sms orders for the online shop.So i need the coding for senting the sms from the pc to mobile and receiving the sms from the mobile to...
1
by: =?Utf-8?B?am1ncm8=?= | last post by:
I created a web service in visual studio 2003, tested it with a sample.xml file from a vendor we are using, and it worked exactly like it should. I deployed it to our server, created a project...
0
by: zelov | last post by:
Hi, I am creating an interface which contains the listbox(C# .net micro framework). When the listbox item is seletected, it will send a character to the serial port and show a "send command"...
2
idsanjeev
by: idsanjeev | last post by:
hello guys how can fixed the table data which display if the word can not be completed in fixed table column then bareak it in new line not expend the column width like when using this table...
3
by: andersond | last post by:
I have a table named 'tableCompletionFeedback' with a cell named 'percent'. In the cell I have placed text ('10% complete") and I want to be able to change the text with javascript. My problem is I...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.