yiisoft/yii2 — pull request #6356 by melfa (2014-12-02 19:32:47+00:00)
Title: #5876 broken pipe handling

# how to reproduce bug
# first set up redis timeout to 5 seconds in /etc/redis/redis.conf as described in http://redis.io/topics/clients
$redisConfig = [
'hostname' => 'localhost',
'port' => 6379,
'connectionTimeout' => 5,
];
$redis = new \yii\redis\Connection($redisConfig);
$redis->executeCommand('PING');

sleep(20);

try {
// this is will cause yii\db\Exception in Connection::parseResponse since Redis dropped connection
$redis->executeCommand('PING');
}
catch (\Exception $e) {
// now Connection::close will try to send QUIT command but got yii\base\ErrorException
// in Connection::executeCommand on fwrite
// So we can't send any command and can't close connection
$redis->close();
}