Skip to content

Commit 5bdf299

Browse files
Merge pull request #14 from open-runtimes/fix-timeout
Fix: Add timeout config
2 parents f389516 + 49cf794 commit 5bdf299

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ OPR_PROXY_WORKER_PER_CORE=6
33
OPR_PROXY_EXECUTORS=mockoon1,mockoon2
44
OPR_PROXY_HEALTHCHECK=enabled
55
OPR_PROXY_HEALTHCHECK_INTERVAL=5000
6+
OPR_PROXY_MAX_TIMEOUT=600
67
OPR_PROXY_ENV=development
78
OPR_PROXY_SECRET=proxy-secret-key
89
OPR_PROXY_EXECUTOR_SECRET=executor-secret-key

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ services:
4747
- OPR_PROXY_WORKER_PER_CORE
4848
- OPR_PROXY_EXECUTORS
4949
- OPR_PROXY_HEALTHCHECK_INTERVAL
50+
- OPR_PROXY_MAX_TIMEOUT
5051
- OPR_PROXY_ENV
5152
- OPR_PROXY_EXECUTOR_SECRET
5253
- OPR_PROXY_SECRET
@@ -111,6 +112,7 @@ docker compose down
111112
| OPR_PROXY_EXECUTORS | Comma-separated hostnames of servers under the proxy. |
112113
| OPR_PROXY_HEALTHCHECK | Health check by HTTP request to /v1/health. 'enabled' by default. To disable, set to 'disabled'. |
113114
| OPR_PROXY_HEALTHCHECK_INTERVAL | Delay in milliseconds between health checks. 10000 by default. Only relevant if OPR_PROXY_HEALTHCHECK is 'enabled'. |
115+
| OPR_PROXY_MAX_TIMEOUT | Maximum timeout in seconds for communication between proxy and executor. Default is 600 seconds. |
114116
| OPR_PROXY_ENV | Runtime environment. 'production' or 'development'. Development may expose debug information and is not recommended on production server. |
115117
| OPR_PROXY_SECRET | Secret that needs to be provided in `Authroization` header when communicating with the to proxy. |
116118
| OPR_PROXY_EXECUTOR_SECRET | String provided as `authorization` header by proxy when sending request to executor. |

app/http.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ function logError(Throwable $error, string $action, ?Logger $logger, Utopia\Rout
303303
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
304304
\curl_setopt($ch, CURLOPT_HEADER, true);
305305
\curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
306+
\curl_setopt($ch, CURLOPT_TIMEOUT, \intval(App::getEnv('OPR_PROXY_MAX_TIMEOUT', '900')));
306307

307308
$curlHeaders = [];
308309
foreach ($headers as $header => $value) {
@@ -326,7 +327,7 @@ function logError(Throwable $error, string $action, ?Logger $logger, Utopia\Rout
326327
\curl_close($ch);
327328

328329
if ($errNo !== 0) {
329-
throw new Exception('Unexpected curl error between proxy and executor: ' . $error);
330+
throw new Exception('Unexpected curl error between proxy and executor ID ' . $hostname . ' (' . $errNo . '): ' . $error);
330331
}
331332

332333
if (!empty($headers)) {

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ services:
3131
- OPR_PROXY_WORKER_PER_CORE
3232
- OPR_PROXY_EXECUTORS
3333
- OPR_PROXY_HEALTHCHECK_INTERVAL
34+
- OPR_PROXY_MAX_TIMEOUT
3435
- OPR_PROXY_ENV
3536
- OPR_PROXY_EXECUTOR_SECRET
3637
- OPR_PROXY_SECRET

0 commit comments

Comments
 (0)