From 4465b276f2f5836b36e4dadddfee1d8fbe7f25fe Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Tue, 16 Dec 2014 03:35:47 +0300 Subject: [PATCH] Add timeout (sometimes twisterd doesn't response) --- twisterpost.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/twisterpost.php b/twisterpost.php index a73b3c7..ca729c8 100644 --- a/twisterpost.php +++ b/twisterpost.php @@ -9,6 +9,8 @@ class TwisterPost public $rpchost = '127.0.0.1'; public $rpcport = 28332; + public $timeout = 60; // timeout (in seconds) + public $lastError = null; protected $maxId = false; @@ -47,6 +49,8 @@ class TwisterPost curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout); $response_json = curl_exec($ch);