# Transport Client hangs in my web application during search

**URL:** <https://discuss.elastic.co/t/transport-client-hangs-in-my-web-application-during-search/15131>\
**Category:** Elasticsearch\
**Created:** [January 7, 2014, 8:41pm UTC](https://discuss.elastic.co/t/transport-client-hangs-in-my-web-application-during-search/15131 "2014-01-07T20:41:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![search](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@search](https://discuss.elastic.co/u/search)\
**Post date:** [January 7, 2014, 8:41pm UTC](https://discuss.elastic.co/t/transport-client-hangs-in-my-web-application-during-search/15131/1 "2014-01-07T20:41:10Z")

</div>

I have a web application in which I create a Transport Client using Spring  
(singleton) and inject it into my service. When I receive a request in my  
controller, controller calls the service and service uses the transport  
client to execute the query and return the results. When I deploy this  
application in tomcat, I have the client created but when I execute the  
query, client hangs.

If I create the client for every request (in my service) and run the query,  
everything is fine. Can some one help me understand this behavior?

Following is my code to create the Client object.

Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",  
"mysearchcluster").put("client.transport.sniff", true).build();  
Client client = new TransportClient(settings).addTransportAddress(new  
InetSocketTransportAddress("10.150.200.101", 9300));

Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4c846ec4-15c5-4c6f-9e1c-6c56912cc2ee%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4c846ec4-15c5-4c6f-9e1c-6c56912cc2ee%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)\
**Post date:** [January 8, 2014, 6:40am UTC](https://discuss.elastic.co/t/transport-client-hangs-in-my-web-application-during-search/15131/2 "2014-01-08T06:40:45Z")

</div>

Does it show anything in the log? Perhaps try catch block on your code and  
set a query timeout.

HTH

/Jason

On Wed, Jan 8, 2014 at 4:41 AM, Search User [feedworks@gmail.com](mailto:feedworks@gmail.com) wrote:

> I have a web application in which I create a Transport Client using Spring  
> (singleton) and inject it into my service. When I receive a request in my  
> controller, controller calls the service and service uses the transport  
> client to execute the query and return the results. When I deploy this  
> application in tomcat, I have the client created but when I execute the  
> query, client hangs.
> 
> If I create the client for every request (in my service) and run the  
> query, everything is fine. Can some one help me understand this behavior?
> 
> Following is my code to create the Client object.
> 
> Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name"  
> , "mysearchcluster").put("client.transport.sniff", true).build();  
> Client client = new TransportClient(settings).addTransportAddress(new  
> InetSocketTransportAddress("10.150.200.101", 9300));
> 
> Thanks
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/4c846ec4-15c5-4c6f-9e1c-6c56912cc2ee%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4c846ec4-15c5-4c6f-9e1c-6c56912cc2ee%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAHO4itxM795Xuo8tikF4oADgYH50R58Y8B0qwdMz4nU82koN3w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAHO4itxM795Xuo8tikF4oADgYH50R58Y8B0qwdMz4nU82koN3w%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [January 8, 2014, 7:20am UTC](https://discuss.elastic.co/t/transport-client-hangs-in-my-web-application-during-search/15131/3 "2014-01-08T07:20:26Z")

</div>

Your code looks good to me.  
Don't create multiple client but only one for your whole application.

As Jason wrote, look at logs.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 8 janv. 2014 à 07:40, Jason Wee [peichieh@gmail.com](mailto:peichieh@gmail.com) a écrit :

Does it show anything in the log? Perhaps try catch block on your code and set a query timeout.

HTH

/Jason

> On Wed, Jan 8, 2014 at 4:41 AM, Search User [feedworks@gmail.com](mailto:feedworks@gmail.com) wrote:  
> I have a web application in which I create a Transport Client using Spring (singleton) and inject it into my service. When I receive a request in my controller, controller calls the service and service uses the transport client to execute the query and return the results. When I deploy this application in tomcat, I have the client created but when I execute the query, client hangs.
> 
> If I create the client for every request (in my service) and run the query, everything is fine. Can some one help me understand this behavior?
> 
> Following is my code to create the Client object.
> 
> Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "mysearchcluster").put("client.transport.sniff", true).build();  
> Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("10.150.200.101", 9300));
> 
> ## Thanks
> 
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4c846ec4-15c5-4c6f-9e1c-6c56912cc2ee%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4c846ec4-15c5-4c6f-9e1c-6c56912cc2ee%40googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAHO4itxM795Xuo8tikF4oADgYH50R58Y8B0qwdMz4nU82koN3w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAHO4itxM795Xuo8tikF4oADgYH50R58Y8B0qwdMz4nU82koN3w%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/FD569ACE-1811-4FEC-AFDC-7DA96A621B61%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/FD569ACE-1811-4FEC-AFDC-7DA96A621B61%40pilato.fr).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Vijay\_Tiwary](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@Vijay\_Tiwary](https://discuss.elastic.co/u/Vijay_Tiwary)\
**Post date:** [September 26, 2014, 7:41am UTC](https://discuss.elastic.co/t/transport-client-hangs-in-my-web-application-during-search/15131/4 "2014-09-26T07:41:51Z")

</div>

If you turn off your sniff settings to false it will work.

On Wednesday, January 8, 2014 2:11:10 AM UTC+5:30, Search User wrote:

> I have a web application in which I create a Transport Client using Spring  
> (singleton) and inject it into my service. When I receive a request in my  
> controller, controller calls the service and service uses the transport  
> client to execute the query and return the results. When I deploy this  
> application in tomcat, I have the client created but when I execute the  
> query, client hangs.
> 
> If I create the client for every request (in my service) and run the  
> query, everything is fine. Can some one help me understand this behavior?
> 
> Following is my code to create the Client object.
> 
> Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name"  
> , "mysearchcluster").put("client.transport.sniff", true).build();  
> Client client = new TransportClient(settings).addTransportAddress(new  
> InetSocketTransportAddress("10.150.200.101", 9300));
> 
> Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f48f2929-f9e9-4576-823b-42563004fe10%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f48f2929-f9e9-4576-823b-42563004fe10%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:59am UTC](https://discuss.elastic.co/t/transport-client-hangs-in-my-web-application-during-search/15131/5 "2017-07-06T00:59:46Z")

</div>


