Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CurlMultiHandler with PHP 5.4 [v2.0.0-beta1] #201

Closed
simplechris opened this issue Mar 19, 2015 · 5 comments
Closed

CurlMultiHandler with PHP 5.4 [v2.0.0-beta1] #201

simplechris opened this issue Mar 19, 2015 · 5 comments

Comments

@simplechris
Copy link
Contributor

I'm trying out the new v2.0.0-beta1, but I'm having some trouble with the async/future mode, using with PHP 5.4. The problem seems to be with Elasticsearch\ClientBuilder::multiHandler()

<?php

require 'vendor/autoload.php';

// Build Client instance
$client = Elasticsearch\ClientBuilder::create()
    ->setHosts(['localhost:9200'])
    ->setHandler(Elasticsearch\ClientBuilder::multiHandler())
    ->build();

Fatal error: Uncaught exception 'RuntimeException' with message 'CurlMulti handler requires cURL.' in /chris/code/playground/elasticsearch-php-2-0-0-beta1-testing/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ClientBuilder.php on line 117

Here's my setup:

$ php -i

PHP Version => 5.4.37
...
curl

cURL support => enabled
cURL Information => 7.37.1
Age => 3
Features
AsynchDNS => Yes
Debug => No
GSS-Negotiate => Yes
IDN => No
IPv6 => Yes
Largefile => Yes
NTLM => Yes
SPNEGO => No
SSL => Yes
SSPI => No
krb4 => No
libz => Yes
CharConv => No
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, smtp, smtps, telnet, tftp
Host => x86_64-apple-darwin14.0
SSL Version => SecureTransport
ZLib Version => 1.2.5

so, when running PHP 5.4 with cURL, the above exception gets thrown I think due to this check for curl_reset which the documentation states to be a >= PHP 5.5 feature. Before I provide a patch, I wanted to check if there was a particular reason to check for curl_reset and not curl_multi_init?

@polyfractal
Copy link
Contributor

Whoops, that is indeed a problem. I have no preference for curl_reset vs curl_multi_init, I actually lifted that snippet from the Guzzle code that sets up similar handlers.

A patch would be gladly accepted!

@polyfractal
Copy link
Contributor

Just pushed a fix, sorry for the long delay on this...got caught up in other things.

@simplechris
Copy link
Contributor Author

I'm having a few other issues with 5.4, I'm debugging now but think the issues will have to be patched upstream in guzzle.

@polyfractal
Copy link
Contributor

Ok...let me know if you want a hand debugging, would be happy to help.

@simplechris
Copy link
Contributor Author

Ok, from looking at the upstream issue in RingPHP [https://github.com/guzzle/RingPHP/issues/23] , it looks as if curl_reset/PHP5.5 is dubiously required for the CurlHandler, which means checks in ClientBuilder::defaultHandler() and ClientBuilder::singleHandler() are required.

The CurlMultiHandler will be available in all environments with curl enabled, just not the CurlHandler, but ClientBuilder::defaultHandler() will fall back to the multihandler when curl_reset is not available.

PR incoming...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants