The DevCenter has moved!

The Developer Center has a new home, developer.ektron.com. The site you are currently viewing is available as a read-only archive.
Things to note:
  1. Your username & password is the same on the new site, developer.ektron.com
  2. Going forward, please use the new URL, developer.ektron.com
  3. The old discussion forums and old KB articles are still available as an archive (read-only)
RSS Feed Print Category View
RSS feed connection failed
iwilliam
Posted: Friday, April 20, 2007 10:33 AM
Joined: 11/1/2006
Posts: 62


I have an RSS feed on our main page that connects to our corporate office to get the company news but if their site is down i get the following message and disbales that page which is our home page.

----error message

Exception Details: System.Net.Sockets.SocketException: 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

Source Error:

Line 305: 'Pull menu data Line 306: Dim rss As New XmlDocument Line 307: rss.Load(_rssUrl) Line 308: Line 309: If (_maxResults > 0) Then

Source File: C:\Inetpub\wwwroot\CMSWeb400\RssAggregator.ascx.vb    Line: 307

-----RSS

<uc2:RssAggregator ID="RssAggregator1" DisplayXslt="XSL/Teaser1_rss.xslt" runat="server"

URL="http://www.usa.com/rss/press_releases.xml" Visible="True" CacheInterval="5">

</uc2:RssAggregator>

how do i set a timeout for this user control so that when the  site it is trying to connect to is down,  it does not give me the message above but i can place an other message in that section to let the user know that the site is temporarily unavailable?

 


EktronKala
Posted: Friday, April 20, 2007 2:32 PM
Joined: 4/2/2007
Posts: 151


Could you please send us codebehind for RSSAggregator.ascx and RSSAggregator.ascx.vb?

so that we can take a look at it and help you.

 

Thanks

-kala.


eGandalf
Posted: Friday, April 20, 2007 2:53 PM
Joined: 9/13/2006
Posts: 2950


I would recommend checking if the URL exists first, which the control is not doing for you. There are a couple of articles on the web about how to do this.

http://cgaskell.wordpress.com/2006/12/05/check-url-validity-aspnet/
It uses a Try-Catch which they say increases the overhead.

Or this:
http://www.velocityreviews.com/forums/t64579-is-it-possible-to-check-the-existence-of-a-url-in-aspnet.html

Or whatever else you can find. Some suggest using the HttpWebRequest object, which may also be worth looking into. I think it will return 404 responses and the like in some programmatically recognizable fashion.

I'd recommend writing a url checking function that returns true/false for url validity and then programmatically setting up the uc2RssAggregator control. Something like:

If CheckValidUrl("http://www.usa.com/rss/press_releases.aspx") = True Then
    RssAggregator1.URL = "http://www.usa.com/rss/press_releases.aspx"
Else
    RssAggregator1.Visible = False
    lblRssDown.Text = "Feed Unavailable"
End If


iwilliam
Posted: Friday, April 20, 2007 3:23 PM
Joined: 11/1/2006
Posts: 62


eGandalf

I'd like to use your example but not sure what I need to import as in

Imports system.XXXXX

I tried using

Imports System.web.HttpRequest

but it is showing that CheckValidUrl is not declared.

 


eGandalf
Posted: Friday, April 20, 2007 3:57 PM
Joined: 9/13/2006
Posts: 2950


iwilliam,

Sorry for the confusion. CheckValidURL would be the function you need to write using the aformentioned articles as examples of possible ways to achieve what you want.

I'll try to come up with a workable function and post back for you.

eGandalf
Posted: Friday, April 20, 2007 4:13 PM
Joined: 9/13/2006
Posts: 2950


Try this:

Protected Function CheckValidUrl(ByVal Url As String) As Boolean
  Dim sStream As IO.Stream
  Dim URLReq As Net.HttpWebRequest
  Dim URLRes As Net.HttpWebResponse
  Try
    URLReq = System.Net.WebRequest.Create(Url)
    URLRes = URLReq.GetResponse()
    sStream = URLRes.GetResponseStream()
    Dim reader As String = New System.IO.StreamReader(sStream).ReadToEnd()
    Return True
  Catch ex As Exception
    'Url not valid
    Return False
  End Try
End Function



You can see how it works here: http://www.kdmc.com/test_url.aspx

I don't have the RssAggregator control, so the code sample I provided previously may need to be adjusted to work with your page. I only provided it as an example.

iwilliam
Posted: Friday, April 20, 2007 4:23 PM
Joined: 11/1/2006
Posts: 62


Never mind  I decided to use the rssaggregator that is built in in CMS instead of using the user control.

 

Thank you for the assistance

 


 

Jump to different Forum...