Page 1 of 1
Wurfl Cloud Server unable to connect
Posted: Wed Aug 05, 2015 2:54 am
by jetsynthesys
We're getting curl error "unable to contact server'
Fatal error: Uncaugh exception 'ScientiaMobile\WurflCloud\HttpClient\HttpException' with message 'Unable to contact server: cURL
Error: Resolving timed out after 1251 milliseconds'
Re: Wurfl Cloud Server unable to connect
Posted: Wed Aug 05, 2015 8:55 am
by Elliotfehr
Hello,
Are you seeing this error on a regular basis? Is this timeout occurring on production servers or only in a local development environment while testing? Are you also able to provide me with the geographic region that these requests are originating from?
Thank you,
Elliot
Re: Wurfl Cloud Server unable to connect
Posted: Thu Aug 06, 2015 4:56 am
by jetsynthesys
Hi Elliot,
This error is occurring occasionally on production server and the geographic region from where the requests are origination is India.
Re: Wurfl Cloud Server unable to connect
Posted: Thu Aug 06, 2015 11:23 am
by Elliotfehr
It is not totally unusual to see a few failed HTTP requests per day considering the nature of the public internet. The WURFL cloud will typically answer requests in 2 milliseconds or less and the cloud client is set by default to forcefully close any requests that take over a second. I have posted a code snippet on how to raise this timeout below:
Code: Select all
<?php
require_once __DIR__.'/../src/autoload.php';
use ScientiaMobile\WurflCloud\Config;
use ScientiaMobile\WurflCloud\Client;
use ScientiaMobile\WurflCloud\Cache\Cookie;
use ScientiaMobile\WurflCloud\HttpClient\Curl;
try {
// Create a WURFL Cloud Config
$config = new Config();
// Set your API Key here
$config->api_key = '123456:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
// Create an HTTP Client
$http_client = new Curl();
// Increase the timeout if there are issues connecting
$http_client->setTimeout(3000);
// Create a WURFL Cloud Client
$client = new Client($config, new Cookie(), $http_client);
// Detect the visitor's device
$client->detectDevice();
// Show all the capabilities returned by the WURFL Cloud Service
foreach ($client->capabilities as $name => $value) {
echo "<strong>$name</strong>: ".(is_bool($value)? var_export($value, true): $value) ."<br/>";
}
} catch (Exception $e) {
// Show any errors
echo "Error: ".$e->getMessage();
}