RE: System.Net.HttpWebRequest - Unable to connect to the remote server
- From: Brad Roberts <BradRoberts56nojunk@xxxxxxxxxxx>
- Date: Fri, 26 Aug 2005 07:21:03 -0700
I had a similar problem. But my app was working for a year and just stopped.
I noticed that you were setting the HTTP Useragent and I wasn't. I set it and
it works now. I guess the "black hole" turned on this requirement on the
proxy server. Thanks for posting your code.
"tbdean@xxxxxxxxx" wrote:
> I'm having a bit of a problem with System.Net.HttpWebRequest. I've also
> tried Net.WebClient with the same results.
>
> The odd thing is that this works fine in the IDE, it's just once I
> build and run from the EXE that it give me the problem.
>
> Here is my code:
>
> 'Create web request object
> Dim webRequest As System.Net.HttpWebRequest
> webRequest =
> System.Net.HttpWebRequest.Create("http://ip.addr.ess:port/page?data=" &
> XML)
> webRequest.Proxy = System.Net.GlobalProxySelection.GetEmptyWebProxy()
> webRequest.KeepAlive = False
>
> 'Set user agent
> webRequest.UserAgent = "ourname - HTTPWebRequest"
>
> 'Add authorization header
> Dim CredCache As System.Net.CredentialCache
> CredCache = New System.Net.CredentialCache
> CredCache.Add(New Uri("ip.addr.ess"), "Basic", New
> System.Net.NetworkCredential("ourname", "ourpassword"))
> webRequest.PreAuthenticate = True
> webRequest.Credentials = CredCache
> CredCache = Nothing
>
> 'Send / get resonse
> Dim objStream As System.IO.Stream
>
> 'Error comes here after about 30 seconds:
> objStream = webRequest.GetResponse.GetResponseStream
>
> The error is "The underlying connection was closed: Unable to connect
> to the remote server." I've tried it with other URLs and it works fine.
> I've even tried it with IP only URLs, and IP only URLs with non
> standard ports, and it still works. I've even tried setting up my local
> copy of IIS to forward to this IP, and have this code connect to
> "localhost". That actually worked, but I couldn't get the
> authentication header to go through.
>
> The server I'm trying to connect to is on a non-standard port, on a
> private IP space, behind a firewall. But like I said, it works fine in
> the IDE.
>
> Thanks so much to anyway that can helP!
>
>
.
- Prev by Date: RE: The underlying connection was closed: Unable to connect to the rem
- Next by Date: Problem converting TIFF to JPEG
- Previous by thread: Re: 2.0 Mail attachment - Content-Type: multipart/related
- Next by thread: Problem converting TIFF to JPEG
- Index(es):
Relevant Pages
|