Open brandfocus opened 9 years ago
Same here, $client->getClient()->setDefaultOption('config/curl/'.CURLOPT_TIMEOUT, 60)
breaks the code.
The readme/doc is outdated and makes references to code not compatible with Guzzle 6. I don't think the setDefaultOption method exists anymore for that version of Guzzle so you might have to consult the latest Guzzle docs to find the equivalent call.
Last I checked, I couldn't find one though so you might have to instantiate a new Guzzle client with your desired settings and inject that into Goutte with the setClient method.
Try this to have a 60 second timeout
$client = new \Goutte\Client();
// Create and use a guzzle client instance that will time out after 60 seconds
$guzzleClient = new \GuzzleHttp\Client(array(
'timeout' => 60,
));
$client->setClient($guzzleClient);
Here's the related guzzle doc link about this setting: http://guzzle.readthedocs.org/en/latest/request-options.html#timeout
@georaldc - it does not break the code any more, but takes no effect on timeout either. I still get the default timeout of 120 secs and fatal error of Maximum execution time of 120 seconds exceeded in \vendor\guzzlehttp\psr7\src\Stream.php on line 115
@rustikov that looks more like a php execution time out error. I tested my example above just now and the timeout value passed is used just fine.
To set curl options by the way, it looks like guzzle recognizes the key "curl" as a config setting, which takes in an array of curl-related config values. So the equivalent of what you were initially trying to achieve would look like the following
$client = new \Goutte\Client();
$guzzleClient = new \GuzzleHttp\Client(array(
'curl' => array(
CURLOPT_TIMEOUT => 60,
),
));
$client->setClient($guzzleClient);
Not sure how well this is supported since it isn't indicated anywhere in the guzzle docs (and doing it this way makes it look like its dependent on CURL, which I think is not the intention of guzzle. Hence the general timeout
config entry). Might be better to ask about it there.
Thanks for the help @georaldc. And yes, that was the php max execution time error, sorry.
This helped me as well thanks!
This helped me as well. Thanks @georaldc!
Thanks, this helped me as well, also works for SSL Certificate.
$guzzleClient = new \GuzzleHttp\Client(array( 'curl' => array( CURLOPT_SSL_VERIFYPEER => false, ), )); $client->setClient($guzzleClient);
I hope you understand what security implications would be from disabling SSL certificate checks.
The setDefaultOption
still break something in the code.
We are receiving the following error with Goutte 3.1 and Guzzle 6.02 while setting curl options:
$client->getClient()->setDefaultOption('config/curl/'.CURLOPT_TIMEOUT, 60);
Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, integer given
fabpot/goutte (v3.1.0) guzzlehttp/promises (1.0.2) psr/http-message (1.0) guzzlehttp/psr7 (1.2.0) guzzlehttp/guzzle (6.0.2)