elastic / elasticsearch-php

Official PHP client for Elasticsearch.
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html
MIT License
35 stars 970 forks source link

How to set the timeout to 100 milliseconds? #1202

Closed Jinnrry closed 2 years ago

Jinnrry commented 2 years ago

Summary of problem or feature request

I need set the timeout to 100 milliseconds.

Code snippet of problem

     $params = [
            'index'  => "index",
            'client' => [
                'timeout'         => 100,  // 100 seconds timeout, but I need to set timeout to 100 milliseconds.
                'connect_timeout' => 100,  // 100 seconds connect timeout
            ],

System details

ezimuel commented 2 years ago

@Jinnrry did you try setting timeout to 0.1 sec (that is 100 milliseconds)?

Jinnrry commented 2 years ago

Yes, it should be set to 0.1. The logic of its code is here

But !!!

Maybe it not work! This is a php curl bug. Look Here

If it not work , You should add curl_setopt($ch, CURLOPT_NOSIGNAL, 1);

ezimuel commented 2 years ago

Thanks @Jinnrry as you mentioned there is this issue that we need to check. We need to verify that the issue is still relevant, since this comment was about 10 years ago. Did you try to set to 0.1 sec?

Jinnrry commented 2 years ago

Yes, But it not work. This is a bug in php curl, not related to the elasticsearch-php. Maybe in newest php, it will work.

My PHP Version: 7.1

Curl Version Info:
[version_number] => 466176 [version] => 7.29.0 [ssl_version] => NSS/3.53.1 [libz_version] => 1.2.7

ezimuel commented 2 years ago

@Jinnrry I suggesto to update your PHP version, at least 7.4 since the previous versions are not supported anymore. I'm closing this issue but I can reopen in the future. Thanks for reporting this issue and let me know if I can help you further.