Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java client can't find master node: MasterNotDiscoveredException waited for [1m]

I'm using vagrant and I installed ES on it using the debian package:

elasticsearch-1.1.1.deb

In my web app, I am using the jar:

org.elasticsearch elasticsearch 1.1.1

I am creating my client like:

val node = nodeBuilder.client(true).node
val client: Client = node.client 

When I try and index I get the error:

val response = client.prepareIndex("articles", "article", article.id.toString).setSource(json).execute.actionGet

The error I get is:

[MasterNotDiscoveredException: waited for [1m]]

I can see my ES instance is working fine by going to:

http://localhost:9200

I ran some test queries from the README file and they worked fine, but now for some reason it isn't working either:

http://localhost:9200/twitter/user/kimchy?pretty=true

I get the error:

{
  "error" : "ClusterBlockException[blocked by: [SERVICE_UNAVAILABLE/1/state not recovered / initialized];[SERVICE_UNAVAILABLE/2/no master];]",
  "status" : 503
}

My vagrant file 2 ports open for elastic search:

  config.vm.network "forwarded_port", guest: 9200, host: 9200 # ES
  config.vm.network "forwarded_port", guest: 9300, host: 9300 # ES

What seems to be the problem?

Note: my web application isn't using a elasticsearch.yml file because it is just connecting to the default localhost:9200 from what I understand.

like image 561
Blankman Avatar asked Dec 07 '25 23:12

Blankman


1 Answers

Normally you have to connect to ES from outside through http (normally, but there are also others protocols available) and then talk REST/JSON. So your webapp should use a scala/java ES client (see http://www.elasticsearch.org/guide/en/elasticsearch/client/community/current/clients.html) and then connect via http to your host which is running ES on port 9200. Port 9300 is only for internode communication (ES is a distributed clustered system). But there is another way to talk remotely to ES: Powerup a node which joins the cluster and then query this node through the internal client. But:

In your above question you try to connect to ES through the internal Java client (internal transport) which starts a node and then try to joins the cluster. That fails because the master node could to be found. Maybe due to networking issues. Try to include elasticsearch.yml in the classpath or use REST like described above. There is also a third option: TransportClient - look http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html#transport-client

See also http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-transport.html and http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-http.html and http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-memcached.html

like image 131
salyh Avatar answered Dec 09 '25 13:12

salyh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!