Skip to content

yii\redis\SocketException: Failed to read from socket. #269

@abidaslam

Description

@abidaslam

I am encountering this issue intermittently on random requests. Based on my observations, it occurs when the connection remains idle for 5 minutes. Our DigitalOcean Redis service has a timeout set to 300 seconds (5 minutes), causing the connection to be closed from the server side. However, Yii Redis does not properly reopen the connection when this happens.

My Yii Redis configuration has retries set to 2, but the issue persists.

I have reviewed the yii\redis\Connection class, which already includes an implementation to handle such scenarios, as referenced in this issue: Exception 'yii\db\Exception' with message 'Failed to read from socket. #91. However, it seems that the fix does not work in all cases.

Could you please look into this? Please let me know if you need any more details.

Trace:

[error][yii\redis\Connection::executeCommand] yii\redis\SocketException: Failed to read from socket.
Redis command was: GET LIVE_price_table in public/vendor/yiisoft/yii2-redis/src/Connection.php:850
Stack trace:
#0 public/vendor/yiisoft/yii2-redis/src/Connection.php(835): yii\redis\Connection->parseResponse(Array, '*2\r\n$3\r\nGET\r\n$2...')
#1 public/vendor/yiisoft/yii2-redis/src/Connection.php(777): yii\redis\Connection->sendRawCommand('*2\r\n$3\r\nGET\r\n$2...', Array)
#2 public/vendor/yiisoft/yii2-redis/src/Connection.php(729): yii\redis\Connection->executeCommand('GET', Array)
#3 public/common/components/redis/RedisHelper.php(145): yii\redis\Connection->__call('get', Array)

Additional Info:
Yii version | 2.0.49.3
PHP version | PHP 7.2.34-38+ubuntu22.04.1+deb.sury.org+1 (cli) (built: Feb 14 2023 18:28:40) ( NTS )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions