gorkalaucirica/HipchatAPIv2Client

Frequent timeouts

Closed this issue · 2 comments

I'm seeing frequent timeouts when calling the userAPI->createUser() method. The following stack trace is shown.

Fatal error: Uncaught exception 'Buzz\Exception\ClientException' with message 'Operation timed out after 5216 milliseconds with 0 out of -1 bytes received' in /Users/mzampetti0264/projects/ie/tools/hipchat/vendor/kriswallsmith/buzz/lib/Buzz/Client/Curl.php:29
Stack trace:
#0 /Users/mzampetti0264/projects/ie/tools/hipchat/vendor/kriswallsmith/buzz/lib/Buzz/Browser.php(130): Buzz\Client\Curl->send(Object(Buzz\Message\Request), Object(Buzz\Message\Response))
#1 /Users/mzampetti0264/projects/ie/tools/hipchat/vendor/kriswallsmith/buzz/lib/Buzz/Browser.php(82): Buzz\Browser->send(Object(Buzz\Message\Request))
#2 /Users/mzampetti0264/projects/ie/tools/hipchat/vendor/kriswallsmith/buzz/lib/Buzz/Browser.php(36): Buzz\Browser->call('https://api.hip...', 'POST', Array, '{"name":"Develo...')
#3 /Users/mzampetti0264/projects/ie/tools/hipchat/vendor/gorkalaucirica/hipchat-v2-api-client/GorkaLaucirica/HipchatAPIv2Client/Client.php(93): Buzz\Browser->post('https://api.hip...', Array, '{"name":"Develo...')
#4 /Users/mzampetti0264/projects in /Users/mzampetti0264/projects/ie/tools/hipchat/vendor/kriswallsmith/buzz/lib/Buzz/Client/Curl.php on line 29

There doesn't appear to be a way to set the timeout or other Curl options, even though the underlying Buzz client allows it.

I've just changed the constructor to allow custom browsers. Now with the latest version you can do the following:

 use Buzz\Browser;
 use Buzz\Client\Curl;
 use GorkaLaucirica\HipchatAPIv2Client\Auth\OAuth2;
 use GorkaLaucirica\HipchatAPIv2Client\Client;

 $curl = new Curl();
 $curl->setTimeout(10);
 $browser = new Browser($curl);
 $auth = new OAuth2('tokenYouCanGetInHipchatSite');
 $client = new Client($auth, $browser);

Let me know if its working for you, thanks!

The changes look good, and I'm able to see better behavior now. Thanks!