Skip to content

Commit 3e72451

Browse files
author
Alexey Gavrilov
committed
thrown connection timeout if it's needed
1 parent 926fc34 commit 3e72451

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

DnodeSyncClient.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ class MethodNotExistsException extends Exception {}
3131
*/
3232
class ConnectionClosedException extends Exception {}
3333

34+
/**
35+
* Thrown when calling method on closed connection
36+
*/
37+
class ConnectionTimeoutException extends Exception {}
38+
3439
/**
3540
* Main Dnode client class
3641
*
@@ -95,6 +100,10 @@ public function __construct($stream) {
95100
// write our (empty) methods description
96101
fputs($this->stream, json_encode(array("method" => "methods")) ."\n");
97102

103+
$streamMeta = stream_get_meta_data($stream);
104+
if ($streamMeta['timed_out'] === true) {
105+
throw new ConnectionTimeoutException("Connection timed out");
106+
}
98107
// read remote methods
99108
$line = fgets($this->stream);
100109
if ($line === false) {

0 commit comments

Comments
 (0)