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

PHP Fatal error in Requests library #300

Closed
AllegroBarry opened this issue Nov 9, 2017 · 3 comments
Closed

PHP Fatal error in Requests library #300

AllegroBarry opened this issue Nov 9, 2017 · 3 comments

Comments

@AllegroBarry
Copy link

AllegroBarry commented Nov 9, 2017

Hi, Sorry to bug you with this... I should probably be able to dig into it and eventually figure it out. But I figured, since you know the code better than I do, maybe you'd have a quick answer?:

PHP Fatal error:  Uncaught exception 'Requests_Exception' with message 'cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received' in /var/www/sites/frantz/photos/requests_lib/library/Requests/Transport/cURL.php:421
Stack trace:
#0 /var/www/sites/frantz/photos/requests_lib/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('', Array)
#1 /var/www/sites/frantz/photos/requests_lib/library/Requests.php(379): Requests_Transport_cURL->request(Object(Requests_IRI), Array, '{"path":"id:cm8...', Array)
#2 /var/www/sites/frantz/photos/requests_lib/library/Requests.php(268): Requests::request('https://api.dro...', Array, '{"path":"id:cm8...', 'POST', Array)
#3 /var/www/sites/frantz/photos/dbxapi.php(97): Requests::post('https://api.dro...', Array, '{"path":"id:cm8...')
#4 /var/www/sites/frantz/photos/dbxapi.php(133): dbx_get_metadata('ptFv6sHgGyAAAAA...', 'id:cm8IQIpr6GAA...')
#5 /var/www/sites/frantz/photos/PhotoLinx2.php(542): dbx_list_folder('ptFv6sHgGyAAAAA...', '/Camera Upload in /var/www/sites/frantz/photos/requests_lib/library/Requests/Transport/cURL.php on line 421

Is it just as simple as, "The remote resource didn't respond, so Requests timed-out..."?

If so, is there something I should have done within my code to catch this, rather than end up with a Fatal error and my program halting?

Thanks,
Barry Lake

@ozh
Copy link
Collaborator

ozh commented Nov 9, 2017

Requests "just" performs HTTP requests, like curl or sockets would do. It's up to you, library user, to deal with various scenarios, just like you would do using plain curl functions for instance.

Requests returns results when there is results to return (which may or may not be a "successful" request, for instance a 404 page) and returns an exception when it could not perform the request.

The typical use would be :

try {
	$result = Requests::request($url, $headers, $data, $type, $options);
	// now do something with $result, like checking if it's a "200 OK" request or something else
} catch( Requests_Exception $e ) {
	// there was an error, do something with $e, for instance
	my_debug_func( $e->getMessage(), $url );
};

@ozh ozh closed this as completed Nov 9, 2017
@arturcesarmelo
Copy link

But if the request need more execution_time, how to increase it?

@soulseekah
Copy link
Contributor

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

4 participants