Aetherdan Posted March 7, 2018 Share Posted March 7, 2018 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 More sharing options...
CodingJungle Posted March 7, 2018 Share Posted March 7, 2018 yes, $query->request(10)->get() you put the timeout as a parameter for request() Link to comment Share on other sites More sharing options...
Aetherdan Posted March 8, 2018 Author Share Posted March 8, 2018 48 minutes ago, CodingJungle said: yes, $query->request(10)->get() you put the timeout as a parameter for request() Is that ms or seconds? Link to comment Share on other sites More sharing options...
CodingJungle Posted March 8, 2018 Share Posted March 8, 2018 seconds Link to comment Share on other sites More sharing options...
Aiwa Posted March 8, 2018 Share Posted March 8, 2018 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 $query->request(\IPS\LONG_REQUEST_TIMEOUT)->get() Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.