diff --git a/lib/InfluxPHP/BaseHTTP.php b/lib/InfluxPHP/BaseHTTP.php index b061a06..776b3f9 100644 --- a/lib/InfluxPHP/BaseHTTP.php +++ b/lib/InfluxPHP/BaseHTTP.php @@ -45,6 +45,7 @@ class BaseHTTP protected $pass; protected $base; protected $timeout; + protected $connectTimeout; protected $timePrecision = 's'; protected $children = array(); @@ -62,6 +63,7 @@ class BaseHTTP $this->port = $c->port; $this->host = $c->host; $this->timeout = $c->timeout; + $this->connectTimeout = $c->connectTimeout; $this->timePrecision = $c->timePrecision; $c->children[] = $this; } @@ -73,8 +75,12 @@ class BaseHTTP $url .= "?" . http_build_query($args); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + var_dump($this->timeout); if($this->timeout !== null){ - curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); + curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); + } + if($this->connectTimeout !== null){ + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout); } return $ch; } diff --git a/lib/InfluxPHP/Client.php b/lib/InfluxPHP/Client.php index 87ef51a..fe079f4 100644 --- a/lib/InfluxPHP/Client.php +++ b/lib/InfluxPHP/Client.php @@ -44,14 +44,16 @@ class Client extends BaseHTTP protected $user; protected $pass; protected $timeout; + protected $connectTimeout; - public function __construct($host = "localhost", $port = 8086, $u = 'root', $p = 'root', $timeout = null) + public function __construct($host = "localhost", $port = 8086, $u = 'root', $p = 'root', $timeout = null, $connectTimeout = null) { $this->host = $host; $this->port = $port; $this->user = $u; $this->pass = $p; $this->timeout = $timeout; + $this->connectTimeout = $connectTimeout; } public function deleteDatabase($name)