• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

responsecode is 404 even if the server is up

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

i need to check whether a URL is up or not.
When i try pinging through command prompt, i get proper response.

But when i try the below code, i get response as 404.

Also through rest client, i get response with proper login id and password.

i tried logging in before getting the response code like below.

But i still get the response as 404.

Am i missing something here??
Is there any other way to check the status of the URL?

Kindly provide me some inputs.

Thanks !!!


 
Sheriff
Posts: 28321
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're getting a 404 response, that means that the server is indeed up, otherwise it couldn't give you that response.
 
Abhishek Mhptr
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick and timely reply Paul.

As per HTTP Status Code Definitions, 404 means "Not Found".
i check for response 200, which means "Okay" and continue with rest of the code.

As my requirement is to check whether the server is up or not, what sort of response i should be looking for??

Is there any other way to handle this??

Thanking you !!!



 
Paul Clapham
Sheriff
Posts: 28321
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the server returns any response at all, then it must have been up. But I already said that, didn't I?

Perhaps your requirements are unclear. Perhaps "up" means something more specific than just running and responding to requests? If you're looking for a 200 response then you have to send a URL which the server can find.
 
Abhishek Mhptr
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Paul..

I was looking for 200 response because i get this response for all other URLs.
Because of authentication error, i must be missing 200. I am not sure how to get rid of 404.

As you have suggested, now i am checking for a response from the URL.
If the response is not empty, i am continuing with the rest of the code.
 
Sheriff
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Authentication problems don't lead to 404 errors but to 401 / 403 errors instead. 404 really means that the URL you are trying to open does not exist.
 
Abhishek Mhptr
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Rob.

As i have mentioned in my first post, if i ping from command prompt, i get a response.
Also through REST client with proper login id and password, i get response:200 for the same URL.

Even if i try logging in before getting the response code as mentioned in the 1st post, i get the response as 404.

I am not sure how to overcome this !!!
 
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic