T
tbdean
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!
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!