Set connect_timeout of elasticsearch php client


(Niv Penso) #1

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


(Niv Penso) #2

I posted the solution in here:

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)
(
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/085d6625-5b18-4566-880e-43bed462ac6e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3