# Simple question about node creation

**URL:** <https://discuss.elastic.co/t/simple-question-about-node-creation/5811>\
**Category:** Elasticsearch\
**Created:** [November 8, 2011, 1:35pm UTC](https://discuss.elastic.co/t/simple-question-about-node-creation/5811 "2011-11-08T13:35:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![steam](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@steam](https://discuss.elastic.co/u/steam)\
**Post date:** [November 8, 2011, 1:35pm UTC](https://discuss.elastic.co/t/simple-question-about-node-creation/5811/1 "2011-11-08T13:35:05Z")

</div>

Hello,  
I have one simple question about node creation.  
Java api according it creates like:

Node node = nodeBuilder().client(true).node();  
Client client = node.client();

My question is: when your application will create clien node to connect and consult index to master server node,  
you always must close node and client after each search query?  
like:  
client.close();  
node.close();

Or only i must close client?

Advance thank you very much.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 9, 2011, 7:12am UTC](https://discuss.elastic.co/t/simple-question-about-node-creation/5811/2 "2011-11-09T07:12:12Z")

</div>

I suggest to close the client and the node only when your application stops.

HTH  
David

Le 8 nov. 2011 à 14:35, steam [grandebuzon@gmail.com](mailto:grandebuzon@gmail.com) a écrit :

> Hello,  
> I have one simple question about node creation.  
> Java api according it creates like:
> 
> Node node = nodeBuilder().client(true).node();  
> Client client = node.client();
> 
> My question is: when your application will create clien node to connect and  
> consult index to master server node,  
> you always must close node and client after each search query?  
> like:  
> client.close();  
> node.close();
> 
> Or only i must close client?
> 
> Advance thank you very much.
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Simple-question-about-node-creation-tp3490292p3490292.html](http://elasticsearch-users.115913.n3.nabble.com/Simple-question-about-node-creation-tp3490292p3490292.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![steam](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@steam](https://discuss.elastic.co/u/steam)\
**Post date:** [November 9, 2011, 7:52am UTC](https://discuss.elastic.co/t/simple-question-about-node-creation/5811/3 "2011-11-09T07:52:18Z")

</div>

I understand, thanks for reply )

---

<div class="post-metadata">

**Author:** ![Andy\_3](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Andy\_3](https://discuss.elastic.co/u/Andy_3)\
**Post date:** [November 15, 2011, 5:54pm UTC](https://discuss.elastic.co/t/simple-question-about-node-creation/5811/4 "2011-11-15T17:54:31Z")

</div>

what if my jvm crashes and I don't close the client. How do the other  
nodes react. I assume (hope) everything will be ok?

thanks!

On Nov 9, 1:12 am, David Pilato [da...@pilato.fr](mailto:da...@pilato.fr) wrote:

> I suggest toclosetheclientand the node only when your application stops.
> 
> HTH  
> David
> 
> Le 8 nov. 2011 à 14:35, steam [grandebu...@gmail.com](mailto:grandebu...@gmail.com) a écrit :
> 
> > Hello,  
> > I have one simple question about node creation.  
> > Java api according it creates like:
> 
> > Node node = nodeBuilder().client(true).node();  
> > Clientclient= node.client();
> 
> > My question is: when your application will create clien node to connect and  
> > consult index to master server node,  
> > you always mustclosenode andclientafter each search query?  
> > like:  
> > client.close();  
> > node.close();
> 
> > Or only i mustcloseclient?
> 
> > Advance thank you very much.
> 
> > --  
> > View this message in context:[http://elasticsearch-users.115913.n3.nabble.com/Simple-question-about](http://elasticsearch-users.115913.n3.nabble.com/Simple-question-about)...  
> > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 15, 2011, 7:07pm UTC](https://discuss.elastic.co/t/simple-question-about-node-creation/5811/5 "2011-11-15T19:07:53Z")

</div>

Yes, either the socket will be broken and immediately identified as a  
failed node, or the fault detection process will identify it.

On Tue, Nov 15, 2011 at 7:54 PM, Andy [apryor48@gmail.com](mailto:apryor48@gmail.com) wrote:

> what if my jvm crashes and I don't close the client. How do the other  
> nodes react. I assume (hope) everything will be ok?
> 
> thanks!
> 
> On Nov 9, 1:12 am, David Pilato [da...@pilato.fr](mailto:da...@pilato.fr) wrote:
> 
> > I suggest toclosetheclientand the node only when your application stops.
> > 
> > HTH  
> > David
> > 
> > Le 8 nov. 2011 à 14:35, steam [grandebu...@gmail.com](mailto:grandebu...@gmail.com) a écrit :
> > 
> > > Hello,  
> > > I have one simple question about node creation.  
> > > Java api according it creates like:
> > 
> > > Node node = nodeBuilder().client(true).node();  
> > > Clientclient= node.client();
> > 
> > > My question is: when your application will create clien node to  
> > > connect and  
> > > consult index to master server node,  
> > > you always mustclosenode andclientafter each search query?  
> > > like:  
> > > client.close();  
> > > node.close();
> > 
> > > Or only i mustcloseclient?
> > 
> > > Advance thank you very much.
> > 
> > > --  
> > > View this message in context:  
> > > [http://elasticsearch-users.115913.n3.nabble.com/Simple-question-about](http://elasticsearch-users.115913.n3.nabble.com/Simple-question-about)...  
> > > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:48am UTC](https://discuss.elastic.co/t/simple-question-about-node-creation/5811/6 "2017-07-06T03:48:32Z")

</div>


