Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP Response : 503

 
shankar vembu
Ranch Hand
Posts: 309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I connect to an external website from my web application using HttpURLConnection. The connection is successful but when I try to get the input stream using the getInputStream() method of HttpURLConnection, I get this error :

My approach to solve this problem involved 3 steps.
1. I tried typing the url directly from the browser and I get a proper response which is actually an xml stream. So there is nothing wrong in the url or the website I am trying to connect to.
2. I also wrote a test java class to test the connection and get the inputstream, it worked fine. So I thought that there is something wrong in my servlet based web application.
3. I restarted my server and then it started working fine.
Well, I have solved my problem but I want to know what exactly went wrong in my server. It was working fine for around 3 months, I never restarted my server during this period, but then I had to restart my server now to solve the above mentioned problem.
Any pointers?
Regards.
[ March 21, 2004: Message edited by: shankar vembu ]
 
Karthik Prabu
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the explanation given in w3.org for 503 response code

10.5.4 503 Service Unavailable
The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.

Note: The existence of the 503 status code does not imply that a
server must use it when becoming overloaded. Some servers may wish
to simply refuse the connection.


[ April 02, 2008: Message edited by: Ulf Dittmer ]
 
shankar vembu
Ranch Hand
Posts: 309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Karthik Prabu:
This is the explanation given in w3.org for 503 response code

10.5.4 503 Service Unavailable
The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.

Note: The existence of the 503 status code does not imply that a
server must use it when becoming overloaded. Some servers may wish
to simply refuse the connection.


thanks for the response, karthik.
I am aware of the reason behind this status code. But as I mentioned in my approach to solve the problem #1, I tried to connect to the service directly from the browser and I got the XML response. Meaning, that this is not an issue of the unavailability of the service, I am trying to connect to. So whose fault is it anyway, my tomcat server ?
Regards.
[ April 02, 2008: Message edited by: Ulf Dittmer ]
 
Victor Maehira
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good night!
I know it is a little late for the post, but it can be usefull for others ranchers. Instead of using HttpUrlConnection, commons-httpclients fits better in this case. I had a similar problem and it solved:

http://hc.apache.org/httpclient-3.x/tutorial.html

Thanks!
 
Avinash Gosi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me in this issue... I am also facing the same problem.
I am getting this error while i try to download the pdf.

Thanks,
Avinash
 
Rob Spoor
Sheriff
Pie
Posts: 20492
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As said before, error 503 (and any other error in the 500 range) is a server error, not a client error.
 
Avinash Gosi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to every one....
I solved this problem... I was setting proxy some where in my code because of that it was throwing this error while getting files from web site....
Then i cleared the proxy then it started working for me...
EX:

System.setProperty("http.proxyHost", proxyHost);
System.setProperty("http.proxyPort", proxyPort);
......
some code...
.......
System.clearProperty("http.proxyHost");
System.clearProperty("http.proxyPort");

Thanks,
Avinash
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic