1

In Reuters' RSS web services, loading rss feeds from certain countries throws java.net.ProtocolException: Too many redirects on loading RSS feed on both UI and Background . (Specially in case of two countries: INDIA and USA) .

How can I solve this issue? Did anybody successfully solved this problem.

Thanks in advance.

Prasham
  • 6,646
  • 8
  • 38
  • 55
  • Can you provide a sample RSS URL for one that fails? This error is usually caused by circular redirects `A->B->C->A` but as it's onty for certain countries, it's possible you're simply getting enough redirects to hit the internal limit. You may be able to follow the path of the redirects and start at a URL further down the chain... – Basic Nov 19 '10 at 13:37
  • 2
    Have you tried using the HttpClient classes? This error feels like it is coming perhaps from `HttpUrlConnection`. – CommonsWare Nov 19 '10 at 13:38
  • @CommonsWare I use a factory method for parsing xml of RSS feeds, here is its code `URL url = new URL(urlString); InputSource inputSource = new InputSource(url.openStream());` This code is further used to Document `(org.w3c.Document)` Parsing. In this situation what alternative do you propose? – Prasham Nov 19 '10 at 13:51
  • 2
    You might consider switching to HttpClient, since that is built into Android and is Google's recommended choice for HTTP requests. I think there are ways you can have finer-grained control over how it handles redirects, though I have not run into your specific problem yet and therefore do not know whether it will help in your case. – CommonsWare Nov 19 '10 at 13:55
  • @CommonsWare: Thanks, your suggestion is worked with little bit of tweaking in code. I have applied that tweaking in my centralized method and it worked like a charm. – Prasham Nov 30 '10 at 05:44

1 Answers1

0

(Question answered in the comments. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )

@CommonsWare wrote:

Have you tried using the HttpClient classes? This error feels like it is coming perhaps from HttpUrlConnection.

You might consider switching to HttpClient, since that is built into Android and is Google's recommended choice for HTTP requests. I think there are ways you can have finer-grained control over how it handles redirects, though I have not run into your specific problem yet and therefore do not know whether it will help in your case.

The OP wrote:

I use a factory method for parsing xml of RSS feeds, here is its code URL url = new URL(urlString); InputSource inputSource = new InputSource(url.openStream()); This code is further used to Document (org.w3c.Document) Parsing.

Thanks, your suggestion is worked with little bit of tweaking in code. I have applied that tweaking in my centralized method and it worked like a charm.

Community
  • 1
  • 1
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129