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: -
-
WebRequest request = WebRequest.Create(URL);
-
-
try
-
{
-
request.Timeout = 50000;
-
WebResponse response = request.GetResponse();
-
}
-
catch(Exception ex)
-
{
-
WriteToLog(LogType.Info,ex.Message.ToString());
-
response = null;
-
}
-
-
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
22 3271
Unbelievable,
I just had contact with my Romanian friend... He installed ethereal and
tried it... And the program just worked...
The only thing I did was to save the generated xml in utf-8,
yesterday... That must have been the solution...
Very strange,
But thank you all for trying to help me on this one...
If you are in Belgium sometime, give me a call, I'll buy you a drink :D
ciao
Kristof Thys wrote: I'm sorry for my stupidity, but I don't know exactly what you are talking about... I'm not using a http logging proxy, but where can I download something like that and how can I use it? What does it do exactly?
thx
at wrote:
That makes it rather difficult! But...
Can you have the client person in Romania use a http logging proxy? So that you can get at the headers being send? Do you run a client yourself as well by the way? Do you get the headers it sends?
"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message news:d1******** **@ikaria.belne t.be...
I don't own the server, so running ethereal there is a problem... Running ethereal on the failing client isn't easy neither, because the failing client situates in Romania, while I'm from Belgium...
But when I try to change my IE settings, and block all cookies, everything keeps working... Even browsing to the url with IE...
Tricky problem :S
at wrote:
If you use ethereal on the serverside and run a working client, do you see any cookie stuff in the received http headers? It looks to me the client that does not work does not send cookie. It is my assumption that a cookie should be passed as part of the request.
If you are unable to sit behind the server, check cookie settings on the client.
Or, use I.E. from the failing client and see what headers get send.
"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message news:d1******** **@ikaria.belne t.be...
> at wrote: > > >> What is the url? String, uri? >> >> What do you get in s? >> >> string s; >> HttpWebRequest request = (HttpWebRequest )WebRequest.Cre ate(url); >> HttpWebResponse response; >> try >> { >> response = (HttpWebRespons e)request.GetRe sponse(); >> response.Close( ); >> } >> catch(Exception ex) >> { >> s = ex.ToString(); >> WriteToLog(LogT ype.Info, s); >> } >> response = null; >> >> >> "Kristof Thys" <Kr**********@l uc.ac.be> wrote in message >> news:d1******** **@ikaria.belne t.be... >> >> >> >>> Landi wrote: >>> >>> >>> >>>> You are not going to catch anything with Ethereal. He is not >>>> having any >>>> communication with the server at all and that is why his code is >>>> throwing an >>>> exception. Even if there is anything showing up on the log he >>>> probably wont >>>> know what to look for. >>> >>> >>> The question remains, why isn't there any communication? >>> It is possible to use a browser, IE or any other, to go to the >>> URL from the pc where the program throws an exception at the >>> exact same moment... >>> So it seems to me, the server is just doing fine, but the client >>> pc is blocking the request/response for an unknown reason... >>> >> >> >> > The url is > http://beta.soccerproject.com/man_to...e&pw=newsgroup > > > The exception I'm getting is "The underlying connection was closed: > Unable to connect to the remote server." > And right after that: System.NullRefe renceException: Object > reference not set to an instance of an object. > I don't see where the second exception comes from... > > The exact code is this: > > HttpWebRequest request = (HttpWebRequest )WebRequest.Cre ate(url); > HttpWebResponse response=null; > try > { > response = (HttpWebRespons e)request.GetRe sponse(); > response.Close( ); > } > catch(Exception ex) > { > WriteToLog(LogT ype.Info, ex.ToString()); > } > > if(response == null) > { > CGlobals.WriteT oLog(LogType.In fo,"Response = NULL"); > //He's not coming here... > timeOut = true; > } > > XHTML = ""; > if(!timeOut) > { > StreamReader reader = new treamReader(res ponse.GetRespon seStream()); > XHTML = reader.ReadToEn d(); > } > > > BTW: Thanks for your patient help...
As a matter of fact I am going international coming Friday. I will be in
Brussels the whole day, Rue de Hennin.
Anyway, I take it the problem is solved? If so, I don't get it but that does
not matter ;-)
"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message
news:d1******** **@ikaria.belne t.be... Unbelievable,
I just had contact with my Romanian friend... He installed ethereal and tried it... And the program just worked... The only thing I did was to save the generated xml in utf-8, yesterday... That must have been the solution...
Very strange,
But thank you all for trying to help me on this one... If you are in Belgium sometime, give me a call, I'll buy you a drink :D
ciao
Kristof Thys wrote: I'm sorry for my stupidity, but I don't know exactly what you are talking about... I'm not using a http logging proxy, but where can I download something like that and how can I use it? What does it do exactly?
thx
at wrote:
That makes it rather difficult! But...
Can you have the client person in Romania use a http logging proxy? So that you can get at the headers being send? Do you run a client yourself as well by the way? Do you get the headers it sends?
"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message news:d1******** **@ikaria.belne t.be...
I don't own the server, so running ethereal there is a problem... Running ethereal on the failing client isn't easy neither, because the failing client situates in Romania, while I'm from Belgium...
But when I try to change my IE settings, and block all cookies, everything keeps working... Even browsing to the url with IE...
Tricky problem :S
at wrote:
> If you use ethereal on the serverside and run a working client, do you > see any cookie stuff in the received http headers? It looks to me the > client that does not work does not send cookie. It is my assumption > that a cookie should be passed as part of the request. > > If you are unable to sit behind the server, check cookie settings on > the client. > > Or, use I.E. from the failing client and see what headers get send. > > "Kristof Thys" <Kr**********@l uc.ac.be> wrote in message > news:d1******** **@ikaria.belne t.be... > > >> at wrote: >> >> >>> What is the url? String, uri? >>> >>> What do you get in s? >>> >>> string s; >>> HttpWebRequest request = (HttpWebRequest )WebRequest.Cre ate(url); >>> HttpWebResponse response; >>> try >>> { >>> response = (HttpWebRespons e)request.GetRe sponse(); >>> response.Close( ); >>> } >>> catch(Exception ex) >>> { >>> s = ex.ToString(); >>> WriteToLog(LogT ype.Info, s); >>> } >>> response = null; >>> >>> >>> "Kristof Thys" <Kr**********@l uc.ac.be> wrote in message >>> news:d1******** **@ikaria.belne t.be... >>> >>> >>> >>>> Landi wrote: >>>> >>>> >>>> >>>>> You are not going to catch anything with Ethereal. He is not >>>>> having any >>>>> communication with the server at all and that is why his code is >>>>> throwing an >>>>> exception. Even if there is anything showing up on the log he >>>>> probably wont >>>>> know what to look for. >>>> >>>> >>>> The question remains, why isn't there any communication? >>>> It is possible to use a browser, IE or any other, to go to the URL >>>> from the pc where the program throws an exception at the exact same >>>> moment... >>>> So it seems to me, the server is just doing fine, but the client pc >>>> is blocking the request/response for an unknown reason... >>>> >>> >>> >>> >> The url is >> http://beta.soccerproject.com/man_to...e&pw=newsgroup >> >> The exception I'm getting is "The underlying connection was closed: >> Unable to connect to the remote server." >> And right after that: System.NullRefe renceException: Object >> reference not set to an instance of an object. >> I don't see where the second exception comes from... >> >> The exact code is this: >> >> HttpWebRequest request = (HttpWebRequest )WebRequest.Cre ate(url); >> HttpWebResponse response=null; >> try >> { >> response = (HttpWebRespons e)request.GetRe sponse(); >> response.Close( ); >> } >> catch(Exception ex) >> { >> WriteToLog(LogT ype.Info, ex.ToString()); >> } >> >> if(response == null) >> { >> CGlobals.WriteT oLog(LogType.In fo,"Response = NULL"); >> //He's not coming here... >> timeOut = true; >> } >> >> XHTML = ""; >> if(!timeOut) >> { >> StreamReader reader = new >> treamReader(res ponse.GetRespon seStream()); >> XHTML = reader.ReadToEn d(); >> } >> >> >> BTW: Thanks for your patient help... > > >
This just appeared on codeproject: http://www.codeproject.com/csharp/HTTPeep.asp
"at" <a@t> wrote in message news:42******** *************** @news.xs4all.nl ... As a matter of fact I am going international coming Friday. I will be in Brussels the whole day, Rue de Hennin.
Anyway, I take it the problem is solved? If so, I don't get it but that does not matter ;-)
"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message news:d1******** **@ikaria.belne t.be... Unbelievable,
I just had contact with my Romanian friend... He installed ethereal and tried it... And the program just worked... The only thing I did was to save the generated xml in utf-8, yesterday... That must have been the solution...
Very strange,
But thank you all for trying to help me on this one... If you are in Belgium sometime, give me a call, I'll buy you a drink :D
ciao
Kristof Thys wrote: I'm sorry for my stupidity, but I don't know exactly what you are talking about... I'm not using a http logging proxy, but where can I download something like that and how can I use it? What does it do exactly?
thx
at wrote:
That makes it rather difficult! But...
Can you have the client person in Romania use a http logging proxy? So that you can get at the headers being send? Do you run a client yourself as well by the way? Do you get the headers it sends?
"Kristof Thys" <Kr**********@l uc.ac.be> wrote in message news:d1******** **@ikaria.belne t.be...
> I don't own the server, so running ethereal there is a problem... > Running ethereal on the failing client isn't easy neither, because the > failing client situates in Romania, while I'm from Belgium... > > But when I try to change my IE settings, and block all cookies, > everything keeps working... Even browsing to the url with IE... > > Tricky problem :S > > at wrote: > >> If you use ethereal on the serverside and run a working client, do >> you see any cookie stuff in the received http headers? It looks to me >> the client that does not work does not send cookie. It is my >> assumption that a cookie should be passed as part of the request. >> >> If you are unable to sit behind the server, check cookie settings on >> the client. >> >> Or, use I.E. from the failing client and see what headers get send. >> >> "Kristof Thys" <Kr**********@l uc.ac.be> wrote in message >> news:d1******** **@ikaria.belne t.be... >> >> >>> at wrote: >>> >>> >>>> What is the url? String, uri? >>>> >>>> What do you get in s? >>>> >>>> string s; >>>> HttpWebRequest request = (HttpWebRequest )WebRequest.Cre ate(url); >>>> HttpWebResponse response; >>>> try >>>> { >>>> response = (HttpWebRespons e)request.GetRe sponse(); >>>> response.Close( ); >>>> } >>>> catch(Exception ex) >>>> { >>>> s = ex.ToString(); >>>> WriteToLog(LogT ype.Info, s); >>>> } >>>> response = null; >>>> >>>> >>>> "Kristof Thys" <Kr**********@l uc.ac.be> wrote in message >>>> news:d1******** **@ikaria.belne t.be... >>>> >>>> >>>> >>>>> Landi wrote: >>>>> >>>>> >>>>> >>>>>> You are not going to catch anything with Ethereal. He is not >>>>>> having any >>>>>> communication with the server at all and that is why his code is >>>>>> throwing an >>>>>> exception. Even if there is anything showing up on the log he >>>>>> probably wont >>>>>> know what to look for. >>>>> >>>>> >>>>> The question remains, why isn't there any communication? >>>>> It is possible to use a browser, IE or any other, to go to the URL >>>>> from the pc where the program throws an exception at the exact >>>>> same moment... >>>>> So it seems to me, the server is just doing fine, but the client >>>>> pc is blocking the request/response for an unknown reason... >>>>> >>>> >>>> >>>> >>> The url is >>> http://beta.soccerproject.com/man_to...e&pw=newsgroup >>> >>> The exception I'm getting is "The underlying connection was closed: >>> Unable to connect to the remote server." >>> And right after that: System.NullRefe renceException: Object >>> reference not set to an instance of an object. >>> I don't see where the second exception comes from... >>> >>> The exact code is this: >>> >>> HttpWebRequest request = (HttpWebRequest )WebRequest.Cre ate(url); >>> HttpWebResponse response=null; >>> try >>> { >>> response = (HttpWebRespons e)request.GetRe sponse(); >>> response.Close( ); >>> } >>> catch(Exception ex) >>> { >>> WriteToLog(LogT ype.Info, ex.ToString()); >>> } >>> >>> if(response == null) >>> { >>> CGlobals.WriteT oLog(LogType.In fo,"Response = NULL"); >>> //He's not coming here... >>> timeOut = true; >>> } >>> >>> XHTML = ""; >>> if(!timeOut) >>> { >>> StreamReader reader = new >>> treamReader(res ponse.GetRespon seStream()); >>> XHTML = reader.ReadToEn d(); >>> } >>> >>> >>> BTW: Thanks for your patient help... >> >> >>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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....
|
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
|
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
|
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.UrlPathEncode(sURL))
Line 37: Dim reader As New StreamReader(data)
Line 38: Results = reader.ReadToEnd()
|
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...
| |
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...
|
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
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
| |
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
|
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...
| |