Closed purevirtual closed 6 years ago
Find the solution after reading the source code carefully... https://github.com/yiisoft/yii2-elasticsearch/pull/193
@purevirtual curious to ask, how did you solved this problem?
@purevirtual curious to ask, how did you solved this problem?
see the comments above, I submit a commit next
I use yii2-elasticsearch 2.1 cause I want to connect with Aliyun-es-service[version 5.3] But If failed when start to connect...
What steps will reproduce the problem?
I'm using yii2-elasticsearch 2.1, and this is my component configuration. 'elasticsearch' => [ 'class' => 'yii\elasticsearch\Connection', 'nodes' => [ // configure more hosts if you have a cluster [ 'http_address' => '.elasticsearch.aliyuncs.com:9200', ], ], 'auth' => ['username' => '', 'password' => '**'], ],
Producing following error 2018-08-13 11:49:38 [-][-][-][error][yii\elasticsearch\Exception] yii\elasticsearch\Exception: Elasticsearch request failed: 7 - Failed connect to 192.168.7.211:9200; Connection t imed out in /home/yangchao/project1/vendor/yiisoft/yii2-elasticsearch/Connection.php:504 Stack trace:
0 /home/yangchao/project1/vendor/yiisoft/yii2-elasticsearch/Connection.php(303): yii\elasticsearch\Connection->httpRequest('GET', 'http://192.168....', NULL, false)
1 /home/yangchao/project1/vendor/yiisoft/yii2-elasticsearch/Command.php(156): yii\elasticsearch\Connection->get(Array, Array)
2 /home/yangchao/project1/vendor/yiisoft/yii2-elasticsearch/ActiveRecord.php(149): yii\elasticsearch\Command->get('test-1', 'default', 1, Array)
3 /home/yangchao/project1/console/controllers/UpTestController.php(36): yii\elasticsearch\ActiveRecord::get(1)
4 [internal function]: console\controllers\UpTestController->actionEs()
5 /home/yangchao/project1/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
6 /home/yangchao/project1/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
7 /home/yangchao/project1/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('es', Array)
8 /home/yangchao/project1/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('es', Array)
9 /home/yangchao/project1/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('up-test/es', Array)
10 /home/yangchao/project1/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('up-test/es', Array)
11 /home/yangchao/project1/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
12 /home/yangchao/project1/yii(27): yii\base\Application->run()
13 {main}
Additional Information: Array ( [requestMethod] => GET [requestUrl] => http://192.168.7.211:9200/test-1/default/1 [requestBody] => [responseHeaders] => Array ( )
)
What's expected?
It should be connect. but as per connection.php. It is simply ignoring nodes where http:publish_address key is not available in the response.
What do you get instead?
mentioned above
Additional info
What I know and suggest
1 Why? Aliyun (a china compute cloud service provider like AWS) has SLB and access controller after its main node address [.elasticsearch.aliyuncs.com], so I should and just need to directly use the host rather than node address 2 How? So far, I just add one line code in Connection.php after "$node['http_address'] = $node['http']['publish_address'];" "$node['http_address'] = $host;", and it works so, I suggest, maybe, could you add a member called "$forceUseHost" in Connection.php?