Skip to content

Commit

Permalink
Set the request timeout to 60 seconds by default
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Jul 22, 2019
1 parent 1d47353 commit 8a86c31
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/HuobiFuture.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class HuobiFuture
protected $host;

protected $proxy=false;
protected $timeout=60;

function __construct(string $key='',string $secret='',string $host='https://api.hbdm.com'){
$this->key=$key;
Expand All @@ -32,6 +33,7 @@ private function init(){
'key'=>$this->key,
'secret'=>$this->secret,
'host'=>$this->host,
'timeout'=>$this->timeout,
];
}

Expand All @@ -52,6 +54,13 @@ function setProxy($proxy=true){
$this->proxy=$proxy;
}

/**
* Set the request timeout to 60 seconds by default
* */
function setTimeOut($timeout=60){
$this->timeout=$timeout;
}

/**
*
* */
Expand Down
9 changes: 9 additions & 0 deletions src/HuobiSpot.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class HuobiSpot
protected $host;

protected $proxy=false;
protected $timeout=60;

function __construct(string $key='',string $secret='',string $host='https://api.huobi.pro'){
$this->key=$key;
Expand All @@ -36,6 +37,7 @@ private function init(){
'key'=>$this->key,
'secret'=>$this->secret,
'host'=>$this->host,
'timeout'=>$this->timeout,
];
}

Expand All @@ -56,6 +58,13 @@ function setProxy($proxy=true){
$this->proxy=$proxy;
}

/**
* Set the request timeout to 60 seconds by default
* */
function setTimeOut($timeout=60){
$this->timeout=$timeout;
}

/**
*
* */
Expand Down
5 changes: 4 additions & 1 deletion tests/future/contract.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
include 'key_secret.php';

$huobi=new HuobiFuture($key,$secret);
$huobi->setProxy();
//$huobi->setProxy();

//Set the request timeout to 60 seconds by default
$huobi->setTimeOut(11);

//Place an Order
try {
Expand Down
3 changes: 3 additions & 0 deletions tests/spot/account.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

$huobi=new HuobiSpot($key,$secret);

//Set the request timeout to 60 seconds by default
$huobi->setTimeOut(11);

//get the status of an account
try {
$result=$huobi->account()->get();
Expand Down

0 comments on commit 8a86c31

Please sign in to comment.