• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

"Server redirected too many times (20)" problem

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to open a URL using HttpsURLConnection, but once in a while I got this message: "Server redirected too many times (20)". What can I do? Is this usually something wrong with the java code or the website setup?

Thanks in advance for the help
-Rudy-
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My first reaction would be that this is a problem with the site itself. Does it happen repeatably with specific URLs, or is it more random?
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see this occassionaly where conditional logic on specific servers interferes with conditional logic on another server. Very contrived example:
  • (on American site) If user in France, redirect to French site
  • (on French site) If user searching for something in English, redirect to American site
  • (on American site) If user in France, redirect to French site
  • (on French site) If user searching for something in English, redirect to American site
  • ....
  • (after 20 redirects) Error: Too many redirects
  • You can see how in that contrived example the system would never recover by itself. So there is logic in the servers that notices how many redirects have occured, and stops the infinite loop from occuring.

    Note that although it is user-application logic at fault, it is not the user-application that recovers - the logic to stop after too many redirects is built into most servers.

    Regards, Andrew
     
    Rudy Rusli
    Ranch Hand
    Posts: 114
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    It happens randomly in this particular page I'm accessing.

    Is there any work around this I could do?
     
    (instanceof Sidekick)
    Posts: 8791
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I've only gotten it on a page that redirected to itself. Any chance you have conditional logic that could do that once in a while?
     
    Rudy Rusli
    Ranch Hand
    Posts: 114
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    > Any chance you have conditional logic that could do that once in a while?
    Could this happen in the client side?
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!