dandelionmood/php-lastfm

Timeouts in most endpoints

Closed this issue · 1 comments

The default timeout in Buzz seems to be 5 seconds, which is not for most endpoints in my experience (like user.getRecentTracks). Consider raising it to something like 30 seconds.

$browser = new Browser();
$browser->getClient()->setTimeout(30);

Hi @Krisseck! More than 3 years after the fact, I finally took the time to revamp the code, update dependencies, etc. ;)

I wasn't sure about setting a strict timeout in the code, since it really depends on your use case IMO.

I decided instead to add the ability to tweak the HTTP client request options, which looks like this:

$lfm = new LastFm(
	'YOUR API KEY',
	'YOUR API SECRET'
);
$lfm->set_http_request_options(['timeout' => 1]);
return $this->_lfm()->album_getInfo(array(
	'artist' => 'cher',
	'album' => 'believe'
));

This way you can set the value you need!

It's available in release v0.8.