Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 103cd44

Browse files
committed
Set CONNECTTIMEOUT and TIMEOUT in RpcConnector
1 parent 1059b3b commit 103cd44

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
44
## [Unreleased]
55
#### Changed
66
- RpcConnector now stores cookie into file
7+
- Set CONNECTTIMEOUT and TIMEOUT in RpcConnector
78

89
## [v3.2.0]
910
#### Added

lib/RpcConnector.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
class RpcConnector
3030
{
3131
const COOKIE_FILE = '/tmp/proxyidp_cookie.txt';
32+
const CONNECT_TIMEOUT = 1;
33+
const TIMEOUT = 15;
3234

3335
private $rpcUrl;
3436
private $user;
@@ -61,6 +63,8 @@ public function get($manager, $method, $params = [])
6163
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
6264
curl_setopt($ch, CURLOPT_COOKIEJAR, self::COOKIE_FILE);
6365
curl_setopt($ch, CURLOPT_COOKIEFILE, self::COOKIE_FILE);
66+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, self::CONNECT_TIMEOUT);
67+
curl_setopt($ch, CURLOPT_TIMEOUT, self::TIMEOUT);
6468

6569
$json = curl_exec($ch);
6670
curl_close($ch);
@@ -100,6 +104,8 @@ public function post($manager, $method, $params = [])
100104
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
101105
curl_setopt($ch, CURLOPT_COOKIEJAR, self::COOKIE_FILE);
102106
curl_setopt($ch, CURLOPT_COOKIEFILE, self::COOKIE_FILE);
107+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, self::CONNECT_TIMEOUT);
108+
curl_setopt($ch, CURLOPT_TIMEOUT, self::TIMEOUT);
103109

104110
$json = curl_exec($ch);
105111
curl_close($ch);

0 commit comments

Comments
 (0)