Reputation: 411
I have an Elasticsearch cluster with Compose.io but I can't connect with Elastica Client. This is my configuration :
$elasticaClient = new \Elastica\Client(array(
'servers' => array(
array('host' => 'https://myusername:[email protected]', 'port' => 10050),
array('host' => 'https://myusername:[email protected]', 'port' => 10062)
)
));
$elasticaIndex = $elasticaClient->getIndex('test');
I got this error :
Couldn't resolve host 500 Internal Server Error
How to correctly connect to the database ?
Upvotes: 2
Views: 1598
Reputation: 254
Parameter host
must be specified without protocol.
If you want to use https, you should set transport
parameter to Https
(instead of Http
which used by default).
$elasticaClient = new \Elastica\Client([
'connections' => [
['transport' => 'Https', 'host' => 'myusername:[email protected]', 'port' => 10050],
['transport' => 'Https', 'host' => 'myusername:[email protected]', 'port' => 10062],
],
]);
$elasticaIndex = $elasticaClient->getIndex('test');
Upvotes: 5
Reputation: 206
To test if your issue is Elastica related or if there is an issue with the access to the service (which I assume), use curl:
curl https://myusername:[email protected]:10050
If the server "works" as expected you will get a JSON result with the elasticserach server status. In this case the problem is Elastica related. In all the other cases I assume the problem is somehow related to the firewall settings, issues with the certificate or other server issues and is not Elastica specific.
Please also be aware that using 'servers' array in Elastica is deprecated. Instead of servers 'connections' with the same parameters should be used.
Upvotes: 3