473,729 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem: The underlying connection was closed: Unable to connectto the remote server

Hello,

I'm developing a C# - windows forms application. To get some information
for my application, I'm connecting to an URL, wich gives me XML
generated using php.
With 90% of the users, this code just works fine:

Expand|Select|Wrap|Line Numbers
  1.  
  2. WebRequest request = WebRequest.Create(URL);
  3.  
  4. try
  5. {
  6. request.Timeout = 50000;
  7. WebResponse response = request.GetResponse();
  8. }
  9. catch(Exception ex)
  10. {
  11. WriteToLog(LogType.Info,ex.Message.ToString());
  12. response = null;
  13. }
  14.  
  15.  
But with some users, I get an exception saying: The underlying
connection was closed: Unable to connect to the remote server

I'm sure that there is no firewall on, and I've asked the user to
disable any proxy settings...

Is there something that I'm overseeing or that can be improved to this code?
thanks in advance,

Kristof
Nov 16 '05 #1
22 3265
at
This can happen when the request lacks something like for example a cookie.
Are there other ways in which you can connect? If so, have a look with
ethereal what goes over the wire. That sometimes gives the required
information.

"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message
news:d1******** **@ikaria.belne t.be...
Hello,

I'm developing a C# - windows forms application. To get some information
for my application, I'm connecting to an URL, wich gives me XML generated
using php.
With 90% of the users, this code just works fine:

Expand|Select|Wrap|Line Numbers
  1.  WebRequest request = WebRequest.Create(URL);
  2.  try
  3.  {
  4.  request.Timeout = 50000;
  5.  WebResponse response = request.GetResponse();
  6.  }
  7.  catch(Exception ex)
  8.  {
  9.  WriteToLog(LogType.Info,ex.Message.ToString());
  10.  response = null; }
  11.  

But with some users, I get an exception saying: The underlying connection
was closed: Unable to connect to the remote server

I'm sure that there is no firewall on, and I've asked the user to disable
any proxy settings...

Is there something that I'm overseeing or that can be improved to this
code?
thanks in advance,

Kristof

Nov 16 '05 #2
Kristof,
Your code is fine. It's the URL that you are connecting to that is making
your code throw an exception. I am assuming this is your server that is
giving you the XML; if so then I would make sure that the server is working
properly and that it's never loosing connection.

--
in**@dowhileloo p.com
http://dowhileloop.com website development
http://publicjoe.dowhileloop.com -- C# Tutorials
"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message
news:d1******** **@ikaria.belne t.be...
Hello,

I'm developing a C# - windows forms application. To get some information
for my application, I'm connecting to an URL, wich gives me XML
generated using php.
With 90% of the users, this code just works fine:

Expand|Select|Wrap|Line Numbers
  1.  WebRequest request = WebRequest.Create(URL);
  2.  try
  3.  {
  4.  request.Timeout = 50000;
  5.  WebResponse response = request.GetResponse();
  6.  }
  7.  catch(Exception ex)
  8.  {
  9.  WriteToLog(LogType.Info,ex.Message.ToString());
  10.  response = null;
  11.  }
  12.  

But with some users, I get an exception saying: The underlying
connection was closed: Unable to connect to the remote server

I'm sure that there is no firewall on, and I've asked the user to
disable any proxy settings...

Is there something that I'm overseeing or that can be improved to this code?

thanks in advance,

Kristof

Nov 16 '05 #3
Yep.
When writing these types of apps its important to not presume that the
URL will be available. Its good practice to also double check the
formatting of the XML, but that's not what's happening here.

Nov 16 '05 #4
Mezzrow wrote:
Yep.
When writing these types of apps its important to not presume that the
URL will be available. Its good practice to also double check the
formatting of the XML, but that's not what's happening here.


The strange thing is, that with 19 of the 20 testusers, it is working
just fine. But with one user, it keeps on giving this error...
I believe it must be some kind of setting but I kind find out wich one...
It isn't the firewall, he doesn't have a proxyserver set, and the server
works fine, because at the same moment I'm able to connect...

So I'm really stuck...
Nov 16 '05 #5
at
What difference does ethereal show between a successfull and a failed
attempt?

"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message
news:d1******** **@ikaria.belne t.be...
Mezzrow wrote:
Yep.
When writing these types of apps its important to not presume that the
URL will be available. Its good practice to also double check the
formatting of the XML, but that's not what's happening here.


The strange thing is, that with 19 of the 20 testusers, it is working just
fine. But with one user, it keeps on giving this error...
I believe it must be some kind of setting but I kind find out wich one...
It isn't the firewall, he doesn't have a proxyserver set, and the server
works fine, because at the same moment I'm able to connect...

So I'm really stuck...

Nov 16 '05 #6
I'm not that familiar with ethereal, but I tried installing it (and
wincap3.1) on my pc... But when I run my program, it doesn't seem to
catpure anything...
I don't have to run it on the server pc do I?

There is always the problem to make a program like this run on someone
elses pc, especially when he's living in Romania...

thx for you help
at wrote:
What difference does ethereal show between a successfull and a failed
attempt?

"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message
news:d1******** **@ikaria.belne t.be...
Mezzrow wrote:
Yep.
When writing these types of apps its important to not presume that the
URL will be available. Its good practice to also double check the
formatting of the XML, but that's not what's happening here.


The strange thing is, that with 19 of the 20 testusers, it is working just
fine. But with one user, it keeps on giving this error...
I believe it must be some kind of setting but I kind find out wich one...
It isn't the firewall, he doesn't have a proxyserver set, and the server
works fine, because at the same moment I'm able to connect...

So I'm really stuck...


Nov 16 '05 #7
at
Run ethereal, select Capture/Start from the menu, select an interface (you
see the drop down on top of the ethereal screen?) (I always choose my
netcard to catch anything) and click ok. That is what I do and here it
works. When I click stop it displays what it caught (if anything, you can
test by browsisng to some page somewhere). Client/server side doesn't
matter.

Any luck?

"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message
news:d1******** **@ikaria.belne t.be...
I'm not that familiar with ethereal, but I tried installing it (and
wincap3.1) on my pc... But when I run my program, it doesn't seem to
catpure anything...
I don't have to run it on the server pc do I?

There is always the problem to make a program like this run on someone
elses pc, especially when he's living in Romania...

thx for you help
at wrote:
What difference does ethereal show between a successfull and a failed
attempt?

"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message
news:d1******** **@ikaria.belne t.be...
Mezzrow wrote:

Yep.
When writing these types of apps its important to not presume that the
URL will be available. Its good practice to also double check the
formattin g of the XML, but that's not what's happening here.
The strange thing is, that with 19 of the 20 testusers, it is working
just fine. But with one user, it keeps on giving this error...
I believe it must be some kind of setting but I kind find out wich one...
It isn't the firewall, he doesn't have a proxyserver set, and the server
works fine, because at the same moment I'm able to connect...

So I'm really stuck...



Nov 16 '05 #8
at wrote:
Run ethereal, select Capture/Start from the menu, select an interface (you
see the drop down on top of the ethereal screen?) (I always choose my
netcard to catch anything) and click ok. That is what I do and here it
works. When I click stop it displays what it caught (if anything, you can
test by browsisng to some page somewhere). Client/server side doesn't
matter.

Any luck?

"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message
news:d1******** **@ikaria.belne t.be...
I'm not that familiar with ethereal, but I tried installing it (and
wincap3.1) on my pc... But when I run my program, it doesn't seem to
catpure anything...
I don't have to run it on the server pc do I?

There is always the problem to make a program like this run on someone
elses pc, especially when he's living in Romania...

thx for you help
at wrote:
What difference does ethereal show between a successfull and a failed
attempt?

"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message
news:d1***** *****@ikaria.be lnet.be...
Mezzrow wrote:
>Yep.
>When writing these types of apps its important to not presume that the
>URL will be available. Its good practice to also double check the
>formatti ng of the XML, but that's not what's happening here.
>

The strange thing is, that with 19 of the 20 testusers, it is working
just fine. But with one user, it keeps on giving this error...
I believe it must be some kind of setting but I kind find out wich one...
It isn't the firewall, he doesn't have a proxyserver set, and the server
works fine, because at the same moment I'm able to connect...

So I'm really stuck...

Ok, on my pc this works fine... I see two relevant things, one GET /URL
HTTP/1.1
and one return: HTTP/1.1 200 OK[Unreassembled Packet] with 50 packets or
so following from the same source and with the same destination saying:
Continuation or non-HTTP traffic...

I will try and do the same with the person where it doesn't work, and
I'll let you know the outcome...

Thanks for your cooperation
Nov 16 '05 #9
at
Please note that you can save the captured packets (just use the default
format) so you can compare later on.

In the end you should find a difference somewhere between the captured
packets. That should give you a hint on what is wrong.

"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message
news:d1******** **@ikaria.belne t.be...
at wrote:
Run ethereal, select Capture/Start from the menu, select an interface
(you see the drop down on top of the ethereal screen?) (I always choose
my netcard to catch anything) and click ok. That is what I do and here it
works. When I click stop it displays what it caught (if anything, you can
test by browsisng to some page somewhere). Client/server side doesn't
matter.

Any luck?

"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message
news:d1******** **@ikaria.belne t.be...
I'm not that familiar with ethereal, but I tried installing it (and
wincap3.1) on my pc... But when I run my program, it doesn't seem to
catpure anything...
I don't have to run it on the server pc do I?

There is always the problem to make a program like this run on someone
elses pc, especially when he's living in Romania...

thx for you help
at wrote:

What difference does ethereal show between a successfull and a failed
attempt?

"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message
news:d1**** ******@ikaria.b elnet.be...
>Mezzrow wrote:
>
>
>>Yep.
>>When writing these types of apps its important to not presume that the
>>URL will be available. Its good practice to also double check the
>>formattin g of the XML, but that's not what's happening here.
>>
>
>The strange thing is, that with 19 of the 20 testusers, it is working
>just fine. But with one user, it keeps on giving this error...
>I believe it must be some kind of setting but I kind find out wich
>one...
>It isn't the firewall, he doesn't have a proxyserver set, and the
>server works fine, because at the same moment I'm able to connect...
>
>So I'm really stuck...

Ok, on my pc this works fine... I see two relevant things, one GET /URL
HTTP/1.1
and one return: HTTP/1.1 200 OK[Unreassembled Packet] with 50 packets or
so following from the same source and with the same destination saying:
Continuation or non-HTTP traffic...

I will try and do the same with the person where it doesn't work, and I'll
let you know the outcome...

Thanks for your cooperation

Nov 16 '05 #10

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

Similar topics

0
1102
by: Luis Esteban Valencia | last post by:
I have an application on my intranet It works fine there when I copied the proyect to the server of the Internet it gives me this error. The arquitecture of my servers are. There is one Server for Internet another server for Databases and another server for Intranet. The only one that has public IP is the Internet Server and obviously I cant give public access to the database server. The applicacion access data on the database server....
5
1514
by: David | last post by:
When I call a webservice with an ASP.NET application, I get the following error: "The underlying connection was closed: Unable to connect to the remote server. " With my brower, I can get the asmx page and get the expected output on the page. With a console application, I can call the webservice and retrieve from it
26
16514
by: Rajeev Tipnis | last post by:
http://support.microsoft.com/default.aspx?scid=kb;en- us;819450 Questions: 1) Is this patch (fix) applicable to the .NET 1.1 Framework as well? That is, if we have Framework 1.1 (On Win2K3/IIS6.0), do we still need this patch? 2) Does it specifically solve only this error: The underlying connection was closed. An unexpected error
1
2817
by: Jim | last post by:
I have the following code: Line 35: Dim sURL As String = "http://www.google.com" Line 36: Dim data As Stream = client.OpenRead(Server.UrlPath­Encode(sURL)) Line 37: Dim reader As New StreamReader(data) Line 38: Results = reader.ReadToEnd()
3
4075
by: Rahul Anand | last post by:
As per our requirements we have a web service which internally connects (Simple HTTP Post Request) to a remote server to initiate some work. We are calling the web service method asynchronously from a .NET Web Application hosted on IIS. In our setup the web request form a client can be running for long duration (may be more than 4 hours). We are getting exceptions during the HTTP send/receive inside the web service method. The exception...
3
2098
by: Monty | last post by:
OK, I had an issue with this and found lots of advice that did not apply, so I'm posting what I found hoping it might help someone else. Here's the sitch: you have a COM app that calls to a .Net assembly which in turn calls a web service. You know the web service is reachable and that the COM app is able to instantiate your .Net assembly (because you RegAsm'ed it and it's good to go). However, when you attempt to make a call to the web...
3
9551
by: nandan | last post by:
Yes. My client has a proxy server. That much i know. In my application I make two kinds of calls that are affected by the proxy server I finally got the webservice call working. But my httpwebrequest.GetReponse() function call throws the above error. So here's what i do in the case it works.. //THIS WORKS
0
9427
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9284
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9202
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8151
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2683
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2165
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.