Jump to content

URL Query Timeout


Recommended Posts

Is there any function available in the framework to handle timeout period when querying a url?

// Now fetch it and decode the JSON
try {
    $response = $query->request()->get()->decodeJson();
} catch( \IPS\Http\Request\Exception $e ) {
    die( "There was a problem fetching the request" );
} catch( \RuntimeException $e ) {
    die( "The response was not valid JSON" );


Link to comment
Share on other sites

4 hours ago, CodingJungle said:

yes, $query->request(10)->get()

you put the timeout as a parameter for request()

IPS has constants for default values.  Giving board administrators the option, at a constant level, to adjust the IPS parameters site wide if there are server restrictions in place. 

'DEFAULT_REQUEST_TIMEOUT'	=> 10,		// In seconds - default for most external connections
'LONG_REQUEST_TIMEOUT'		=> 30,		// In seconds - used for specific API-based calls where we expect a slightly longer response time


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...