E
EasyHero
Guest
Hi,
I have been battling this for weeks. I want to read xml string from an rss feed. It works fine on localhost and postman, but after i publish and deploy using FTP to the server, i get this error.
Unable to connect to the remote server at System.Net.HttpWebRequest.GetResponse() at dayrunnerapp.Controllers.HomeController.callRss(String url) System.Net.Sockets.SocketException (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 52.1.31.92:80 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
This is the function that reads the feed
[WebMethod, AllowCrossSiteJson]
private string callRss(string url)
{
string html = String.Empty;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.AutomaticDecompression = DecompressionMethods.GZip;
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.Headers.Add("Accept-Language", "en-gb,en;q=0.5");
request.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
html = reader.ReadToEnd();
}
}
catch (Exception ex)
{
html = ex.Message+"\n"+ex.StackTrace + "\n" + ex.InnerException + "\n" + ex.InnerException.InnerException;
}
return html;
}
this is the feed url
var url = "<![CDATA[Inbound Logistics]]>";
here is part of my web.config file
<system.net>
<defaultProxy useDefaultCredentials="true" />
</system.net>
Please what am i missing?
Easy
Continue reading...
I have been battling this for weeks. I want to read xml string from an rss feed. It works fine on localhost and postman, but after i publish and deploy using FTP to the server, i get this error.
Unable to connect to the remote server at System.Net.HttpWebRequest.GetResponse() at dayrunnerapp.Controllers.HomeController.callRss(String url) System.Net.Sockets.SocketException (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 52.1.31.92:80 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
This is the function that reads the feed
[WebMethod, AllowCrossSiteJson]
private string callRss(string url)
{
string html = String.Empty;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.AutomaticDecompression = DecompressionMethods.GZip;
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.Headers.Add("Accept-Language", "en-gb,en;q=0.5");
request.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
html = reader.ReadToEnd();
}
}
catch (Exception ex)
{
html = ex.Message+"\n"+ex.StackTrace + "\n" + ex.InnerException + "\n" + ex.InnerException.InnerException;
}
return html;
}
this is the feed url
var url = "<![CDATA[Inbound Logistics]]>";
here is part of my web.config file
<system.net>
<defaultProxy useDefaultCredentials="true" />
</system.net>
Please what am i missing?
Easy
Continue reading...