ReadXML through firewall

  • Thread starter Thread starter John
  • Start date Start date
J

John

My firewall appears to be blocking an RSS XML feed from being returned even
thought port 80 is enabled. Can anyone help?

Dim proxyURI As New Uri("http://MyIP:80")

GlobalProxySelection.Select = New WebProxy(proxyURI)

Dim MyXMLDocument As New XPathDocument(http://rss.news.yahoo.com/rss/tech)

Error :

The underlying connection was closed: Unable to connect to the remote server
 
John said:
My firewall appears to be blocking an RSS XML feed from being returned even
thought port 80 is enabled. Can anyone help?

Dim proxyURI As New Uri("http://MyIP:80")

GlobalProxySelection.Select = New WebProxy(proxyURI)

Dim MyXMLDocument As New XPathDocument(http://rss.news.yahoo.com/rss/tech)

Error :

The underlying connection was closed: Unable to connect to the remote server

I added this to the web.config :

<system.net>

<defaultProxy>

<proxy proxyaddress = "http://127.0.0.1:80" bypassonlocal = "true"/>

</defaultProxy>

</system.net>

And now get this error :

The underlying connection was closed: An unexpected error occurred on a
receive
 
If you use WebRequest, you can set the proxy on the request (rather than
globally).
For example, this works for me:

Public Class XpathThruProxy

Private Shared Function GetStreamForUri(Uri As System.String, ProxyUri as
System.String) as System.IO.Stream
Dim req as System.Net.WebRequest
req = System.Net.WebRequest.Create(Uri)
req.Proxy = new System.Net.WebProxy(ProxyUri, true) ' go through a proxy
server
return req.GetResponse().GetResponseStream()
End Function


Public Shared Sub Main()

try
Dim ProxyUri as System.String
ProxyUri= "http://127.0.0.1:3128" ' only if I run a proxy locally
'ProxyUri= "200.244.93.129:3128" ' a remote (working) proxy server

Dim xtr as New
System.Xml.XmlTextReader(GetStreamForUri("http://rss.news.yahoo.com/rss/tech
", ProxyUri))
Dim MyXMLDocument As New System.Xml.XPath.XPathDocument(xtr)

Dim xpn as System.Xml.XPath.XPathNavigator
xpn= MyXMLDocument.CreateNavigator()

Dim expr as System.Xml.XPath.XPathExpression
expr= xpn.Compile("//rss/channel/item")

'Display the selection.
Dim iterator as System.Xml.XPath.XPathNodeIterator = xpn.Select(expr)
while (iterator.MoveNext())
Dim nav2 as System.Xml.XPath.XPathNavigator =
iterator.Current.Clone()
nav2.Select("title")
nav2.MoveToFirstChild()
System.Console.WriteLine(" title: {0}", nav2.Value)
end while

Catch e as System.Exception
System.Console.WriteLine("Exception: " & e.ToString() )

End Try

End Sub

End Class
 
Back
Top