aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes HTTP Response : 503 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "HTTP Response : 503" Watch "HTTP Response : 503" New topic
Author

HTTP Response : 503

shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
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

Joined: Dec 27, 2002
Posts: 48
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

Joined: May 10, 2001
Posts: 309
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

Joined: Mar 08, 2007
Posts: 33
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

Joined: Jul 16, 2008
Posts: 8
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

Joined: Oct 27, 2005
Posts: 19722
    
  20

As said before, error 503 (and any other error in the 500 range) is a server error, not a client error.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Avinash Gosi
Greenhorn

Joined: Jul 16, 2008
Posts: 8
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTTP Response : 503