Closed hpolonkoev closed 6 years ago
hello, you can add a timeout in seconds on stream_socket_client function
stream_socket_client($this->server, $errno, $errstr, 2)
or
stream_socket_client($this->server, $errno, $errstr, ($this->timeout / 1000000))
on RedisClient/Connection/StreamConnection.php on line 95
Hey @hpolonkoev
Param timeout
sets response timeout of server (Redis). The timeout for reading/writing data over the socket,
Timeout means that a server is taking too long to reply to a data request made from a client. Timeouts are not a reply message: they show up when there isn't a reply and a server request is not fulfilled in a predetermined length of time. The purpose of a server timeout is to prevent a client from endlessly waiting for a sever to respond.
Also, please see monitor
example, it uses the timeout configuration:
https://github.com/cheprasov/php-redis-client/blob/master/examples/monitor.php
@hpolonkoev Also, I will release new version on RedisClient soon, and I will add timeout param for connection, not only for reading/writing data over the socket like it is now. Thanks.
@edepietromaria Thanks! This worked for me ;)
@cheprasov Thanks for your explanation;) Waiting for you new release. Until then I'll use the @edepietromaria 's "patch".
@hpolonkoev Done. Version 1.8.0 of RedisClient is released.
I added connection
param to config.
$config = [
...
// Optional. Default = null
// See more here: http://php.net/manual/en/function.stream-socket-client.php
'connection' => [
// Optional. Default = ini_get("default_socket_timeout")
// The timeout only applies while making connecting the socket
'timeout' => 2,
// Optional. Default = STREAM_CLIENT_CONNECT
// Bitmask field which may be set to any combination of connection flags.
// Currently the select of connection flags is limited to STREAM_CLIENT_CONNECT (default),
// STREAM_CLIENT_ASYNC_CONNECT and STREAM_CLIENT_PERSISTENT.
'flags' => STREAM_CLIENT_CONNECT
],
...
];
@cheprasov Thanks a lot! Really apreciate your reactivity ;) And of corse thanks for RedisClient ;)
Hi, I am trying to understand what the timeout is for.
In case the Redis server is unavailable Redis instance doesn't really throw an error or stops after 2 seconds (with the error of timeout). How can I limite the timeout if the redis server is unavailable ?