Mangopay / mangopay2-php-sdk

PHP SDK for MANGOPAY
https://packagist.org/packages/mangopay/php-sdk-v2
MIT License
123 stars 133 forks source link

Please add a curl timeout to RestTool #73

Closed leihog closed 8 years ago

leihog commented 9 years ago

The current RestTool will block indefinitely as there is no timeout set. This isn't a problem when everything is working as it should, but it does become a problem when it's not. A 2-5s(or configurable) timeout value seems reasonable.

hobailey commented 9 years ago

Thanks for the feedback @leihog - we'll look into getting this added in the next set up of updates :-)

shakaran commented 8 years ago

BUMP, there are some progress on this issue @hobailey ?

hobailey commented 8 years ago

@leihog @shakaran I suggest adding to https://github.com/Mangopay/mangopay2-php-sdk/blob/master/MangoPay/Libraries/RestTool.php#L179 something like:

curl_setopt($this->_curlHandle, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($this->_curlHandle, CURLOPT_TIMEOUT, 80);

Would this satisfy your requirements? Or do you have any other suggestions/approaches you'd like to see added?

shakaran commented 8 years ago

@hobailey for me it is a good patch. But it would be better if the 30 and 80 sec would be configurable by the user too, by global settings. See how Stripe is allowing to set the timeout for example too:

https://github.com/stripe/stripe-php/blob/master/lib/HttpClient/CurlClient.php#L98

hobailey commented 8 years ago

Hi @shakaran, I've just updated the SDK - let me know if you have any feedback etc :-)