ruflin / Elastica

Elastica is a PHP client for elasticsearch
http://elastica.io/
MIT License
2.26k stars 734 forks source link

Couldn't resolve host problem #882

Closed ghost closed 8 years ago

ghost commented 9 years ago

Hi,

I have looked and this has been asked before but I haven't managed to get a complete fix for it - so far the only way I can resolve this issue is by commenting out the following lines of code in the Elastica/Transport/Http.php file:

// if ($response->hasError()) { // throw new ResponseException($request, $response); // }

    // if ($response->hasFailedShards()) {
    //     throw new PartialShardFailureException($request, $response);
    // }

    // if ($errorNumber > 0) {
    //     throw new HttpException($errorNumber, $request, $response);
    // }

This problem only happens when I am editing / adding a page etc. in the CMS when using Kunstmann CMS. Is this a versioning problem or a local env problem?

Thanks for your help in advance, and sorry if this is a duplicate.

Harry

im-denisenko commented 9 years ago

@HarryWiseman If you comment out these strings, elastica works as expected? Could you please provide full exception trace and show us snippet of how you create instance of Elastica\Client?

ruflin commented 9 years ago

@HarryWiseman Most interesting is probably the code where you add / edit the page. I'm curious if there is something that changes the host. Instead of commenting the code out above, can you post the full exception here?

ghost commented 9 years ago

Hi, Here is the exception: CRITICAL - Uncaught PHP Exception Elastica\Exception\Connection\HttpException: "Couldn't resolve host" at /Users/harrywisemanwork/Sites/minos-cms/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php line 153

And here is the exception stack trace:

[1] Elastica\Exception\Connection\HttpException: Couldn't resolve host at n/a in /Users/harrywisemanwork/Sites/minos-cms/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php line 153

at Elastica\Transport\Http->exec(object(Request), array('connection' => array('config' => array(), 'host' => 'localhost', 'port' => '9200', 'enabled' => true)))
    in /Users/harrywisemanwork/Sites/minos-cms/vendor/ruflin/elastica/lib/Elastica/Request.php line 167

at Elastica\Request->send()
    in /Users/harrywisemanwork/Sites/minos-cms/vendor/ruflin/elastica/lib/Elastica/Client.php line 587

at Elastica\Client->request('_bulk', 'PUT', '{"index":{"_index":"minosnodeindex","_type":"page_en","_id":"nodetranslation_1"}}

{"node_id":"1","node_translation_id":"1","node_version_id":"1","title":"Home","lang":"en","slug":null,"page_class":"SS\CoreBundle\Entity\Pages\HomePage","created":"2015-06-19T08:32:19+0000","updated":"2015-06-24T13:26:43+0000","view_roles":["ROLE_SUPER_ADMIN","ROLE_ADMIN","IS_AUTHENTICATED_ANONYMOUSLY"],"type":"Home","contentanalyzer":"english","content":"","_boost":1} ', array()) in /Users/harrywisemanwork/Sites/minos-cms/vendor/ruflin/elastica/lib/Elastica/Bulk.php line 342

at Elastica\Bulk->send()
    in /Users/harrywisemanwork/Sites/minos-cms/vendor/ruflin/elastica/lib/Elastica/Client.php line 295

at Elastica\Client->addDocuments(array(object(Document)))
    in /Users/harrywisemanwork/Sites/minos-cms/vendor/kunstmaan/bundles-cms/src/Kunstmaan/SearchBundle/Provider/ElasticaProvider.php line 100

at Kunstmaan\SearchBundle\Provider\ElasticaProvider->addDocuments(array(object(Document)), '', '')
    in /Users/harrywisemanwork/Sites/minos-cms/vendor/kunstmaan/bundles-cms/src/Kunstmaan/SearchBundle/Search/Search.php line 106

at Kunstmaan\SearchBundle\Search\Search->addDocuments(array(object(Document)))
    in /Users/harrywisemanwork/Sites/minos-cms/vendor/kunstmaan/bundles-cms/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php line 226

at Kunstmaan\NodeSearchBundle\Configuration\NodePagesConfiguration->indexNodeTranslation(object(NodeTranslation), true)
    in /Users/harrywisemanwork/Sites/minos-cms/vendor/kunstmaan/bundles-cms/src/Kunstmaan/NodeSearchBundle/EventListener/NodeIndexUpdateEventListener.php line 47

at Kunstmaan\NodeSearchBundle\EventListener\NodeIndexUpdateEventListener->index(object(NodeEvent))
    in /Users/harrywisemanwork/Sites/minos-cms/vendor/kunstmaan/bundles-cms/src/Kunstmaan/NodeSearchBundle/EventListener/NodeIndexUpdateEventListener.php line 38

at Kunstmaan\NodeSearchBundle\EventListener\NodeIndexUpdateEventListener->onPostPersist(object(NodeEvent), 'kunstmaan_node.postPersist', object(TraceableEventDispatcher))
    in  line 

at call_user_func(array(object(NodeIndexUpdateEventListener), 'onPostPersist'), object(NodeEvent), 'kunstmaan_node.postPersist', object(TraceableEventDispatcher))
    in /Users/harrywisemanwork/Sites/minos-cms/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php line 61

at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(NodeEvent), 'kunstmaan_node.postPersist', object(ContainerAwareEventDispatcher))
    in  line 

at call_user_func(object(WrappedListener), object(NodeEvent), 'kunstmaan_node.postPersist', object(ContainerAwareEventDispatcher))
    in /Users/harrywisemanwork/Sites/minos-cms/app/cache/dev/classes.php line 1790

at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener)), 'kunstmaan_node.postPersist', object(NodeEvent))
    in /Users/harrywisemanwork/Sites/minos-cms/app/cache/dev/classes.php line 1723

at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kunstmaan_node.postPersist', object(NodeEvent))
    in /Users/harrywisemanwork/Sites/minos-cms/app/cache/dev/classes.php line 1884

at Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kunstmaan_node.postPersist', object(NodeEvent))
    in /Users/harrywisemanwork/Sites/minos-cms/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php line 124

at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kunstmaan_node.postPersist', object(NodeEvent))
    in /Users/harrywisemanwork/Sites/minos-cms/vendor/kunstmaan/bundles-cms/src/Kunstmaan/NodeBundle/Controller/NodeAdminController.php line 646

at Kunstmaan\NodeBundle\Controller\NodeAdminController->editAction('1', 'public')
    in  line 

at call_user_func_array(array(object(NodeAdminController), 'editAction'), array('1', 'public'))
    in /Users/harrywisemanwork/Sites/minos-cms/app/bootstrap.php.cache line 3039

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
    in /Users/harrywisemanwork/Sites/minos-cms/app/bootstrap.php.cache line 3001

at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
    in /Users/harrywisemanwork/Sites/minos-cms/app/bootstrap.php.cache line 3150

at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
    in /Users/harrywisemanwork/Sites/minos-cms/app/bootstrap.php.cache line 2391

at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
    in /Users/harrywisemanwork/Sites/minos-cms/web/app.php line 40

there has been no set up for anything on my part I am using it with the Kunstmann package which comes with this pre configured.

Thanks,

Harry

ruflin commented 9 years ago

@HarryWiseman Is the elasticsearch instance running on your local machine (localhost)?

ruflin commented 8 years ago

Closing as no updated provided. Please reopen if needed.

matak commented 7 years ago

hi i have same, problem

  1. elastic is not running on same machine
  2. elastic is running, i can create any query through kibana
  3. elastic is version 5.1
  4. the error is number 6, and response is

Elastica\Response #b8e7 _queryTime protected => 2.5144689083099 _responseString protected => "" _error protected => FALSE _transferInfo protected => array (26) _response protected => array () _status protected => 0 _jsonBigintConversion protected => FALSE

matak commented 7 years ago

seems that url was defined with http:// sorry, you library add http to the uri

rastafermo commented 7 years ago

Sorry but I don't understand if this is solved or not. I have a similar problem and I can't find a solution. I've deployed a symfony project on heroku with an elasticsearch add-on up and running, but my symfony app could not resolve the host. Any hint?

ruflin commented 7 years ago

What is the error you get? What is your config? Did you try add / remove http:// etc?

matak commented 7 years ago

remove http:// from the config is enough, this solves the problem, but the elastica library automatically add to the url address http at the begining, we can close this topic

maybe add this note to the documentation, that the url should be defined without http