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
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...
If you have SolrServer
object, just call SolrServer.ping()
it throws exception if can't establish connection.
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.
You should probably use something like Nagios to monitor your hardware status. Nagios also has a nice plugin for solr that can help you.
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.
© 2022 - 2024 — McMap. All rights reserved.