# Set connect\_timeout of elasticsearch php client

**URL:** <https://discuss.elastic.co/t/set-connect-timeout-of-elasticsearch-php-client/19441>\
**Category:** Elasticsearch\
**Created:** [August 25, 2014, 5:24pm UTC](https://discuss.elastic.co/t/set-connect-timeout-of-elasticsearch-php-client/19441 "2014-08-25T17:24:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Niv\_Penso](https://avatars.discourse-cdn.com/v4/letter/n/b487fb/32.png) [@Niv\_Penso](https://discuss.elastic.co/u/Niv_Penso)\
**Post date:** [August 25, 2014, 5:24pm UTC](https://discuss.elastic.co/t/set-connect-timeout-of-elasticsearch-php-client/19441/1 "2014-08-25T17:24:17Z")

</div>

Hey,

i want to configure a a small timeout between my elasticsearch php client  
to the my elasticsearch server.

i tried to pass some parameters to the guzzle client but it seems this  
doesn't work.  
here is the code:

```
$params = array();

```

> ```
> $params['hosts'] = $hosts;
> $params['guzzleOptions']['connect_timeout'] = 2.0;
> $params['guzzleOptions']['timeout'] = 2.0;
> $this->elastica_obj = new Elasticsearch\Client($params);
> 
> ```

i searched and found that the problem might occured because the timeout is  
set in the cURL layer (that is lower than the guzzle)  
([Limit connecting time with Guzzle HTTP PHP client - Stack Overflow](http://stackoverflow.com/questions/20847633/limit-connecting-time-with-guzzle-http-php-client))

i guess i need somehow to set CURLOPT\_CONNECTTIMEOUT\_MS parameter to the  
value i want (2000ms) but i don't see any good way to pass it through the  
elasticsearch php client.

Does someone knows how to do it?

--  
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/cb7eba1e-aa65-4c7f-996f-877b5f1d2639%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cb7eba1e-aa65-4c7f-996f-877b5f1d2639%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Niv\_Penso](https://avatars.discourse-cdn.com/v4/letter/n/b487fb/32.png) [@Niv\_Penso](https://discuss.elastic.co/u/Niv_Penso)\
**Post date:** [August 27, 2014, 8:51am UTC](https://discuss.elastic.co/t/set-connect-timeout-of-elasticsearch-php-client/19441/2 "2014-08-27T08:51:40Z")

</div>

I posted the solution in here:

> <https://stackoverflow.com/questions/25491110/set-connect-timeout-of-elasticsearch-php-client/25522782#25522782>

this is the parameter that should be pass

$params['guzzleOptions']['curl.options'][CURLOPT\_CONNECTTIMEOUT] = 2.0; // this applies 2 seconds connection\_timeout

Niv

On Monday, August 25, 2014 8:24:17 PM UTC+3, Niv Penso wrote:

> Hey,
> 
> i want to configure a a small timeout between my elasticsearch php client  
> to the my elasticsearch server.
> 
> i tried to pass some parameters to the guzzle client but it seems this  
> doesn't work.  
> here is the code:
> 
> ```
> $params = array();
> 
> ```
> 
> > ```
> > $params['hosts'] = $hosts;
> > $params['guzzleOptions']['connect_timeout'] = 2.0;
> > $params['guzzleOptions']['timeout'] = 2.0;
> > $this->elastica_obj = new Elasticsearch\Client($params);
> > 
> > ```
> 
> i searched and found that the problem might occured because the timeout is  
> set in the cURL layer (that is lower than the guzzle)  
> (  
> [Limit connecting time with Guzzle HTTP PHP client - Stack Overflow](http://stackoverflow.com/questions/20847633/limit-connecting-time-with-guzzle-http-php-client)  
> )
> 
> i guess i need somehow to set CURLOPT\_CONNECTTIMEOUT\_MS parameter to the  
> value i want (2000ms) but i don't see any good way to pass it through the  
> elasticsearch php client.
> 
> Does someone knows how to do it?

--  
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/085d6625-5b18-4566-880e-43bed462ac6e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/085d6625-5b18-4566-880e-43bed462ac6e%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, 1:06am UTC](https://discuss.elastic.co/t/set-connect-timeout-of-elasticsearch-php-client/19441/3 "2017-07-06T01:06:04Z")

</div>


