How to find whether solr server is running or not
Asked Answered
C

5

11

I am running an application that get search results from solr server. But when server is not running i get no response from the server. Is there any way i can found that my server is not running so that i can give proper error message regarding it

Cadwell answered 19/7, 2011 at 9:7 Comment(0)
R
9

You could periodically ping your server (e.g. http://localhost:8983/solr/admin/ping) and in case of an error pass that message on to the frontend...

Rollie answered 19/7, 2011 at 13:52 Comment(4)
:how should i ping solr server through the code base so that i got the error.Cadwell
Your programming language probably has some facility for scheduling jobs to be run on a regular basis (e.g. quartz-scheduler.org for Java...) Then just send a GET request to the ping URL and process the HTTP status response accordingly...Rollie
I know this is an older answer but it no longer applies to the latest Solr.Lamont
localhost:8983/solr/<core>/admin/ping applies to the latest Solr.Halfsole
T
4

If you have SolrServer object, just call SolrServer.ping() it throws exception if can't establish connection.

Tracheid answered 17/2, 2013 at 15:4 Comment(0)
O
1

If the server is not responding in a timely manner (solr) then you should consider representing it being down and present the error message regardless of whether it is or not (ie its taking a long time because its overloaded). If it takes forever to load its down to the user :)

Most solr clients have a timeout and an error callback of some sort. If the timeout happens then you show the error.

If you want to know very quickly that the server is down you can put a JSP on solr that does nothing but print out a message. Then do a HTTP GET to the JSP and if it doesn't come up very quickly then the server is down.

Ordnance answered 19/7, 2011 at 12:4 Comment(1)
I think, from the client side, a timeout approach is wiser than periodically pinging the server.Psychophysiology
M
0

You should probably use something like Nagios to monitor your hardware status. Nagios also has a nice plugin for solr that can help you.

Methyl answered 19/7, 2011 at 11:35 Comment(2)
Nagios is not going to really help that much if he is trying to handle this in his frontend (error message).Ordnance
well he didn't specify too much, nagios is the most stand-alone solution i could think of.Methyl
B
0

Seems like there should be a simple way to do this via HTTP, a generic on/off response from the server would be ideal. Short of that, one thing you could do is just GET host:port/solr and if you get any response other than 200 then assume it's down.

Bastien answered 5/1, 2021 at 14:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.