You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's because in this commit c0879ec the default for $port has been set to 6379 instead of null. So the redis connection is using a port with a unix-socket. This throws a RedisException with php_network_getaddresses: getaddrinfo failed: Name or service not known
…v80)
This PR was merged into the 4.4 branch.
Discussion
----------
[Cache] Fix connecting to Redis via a socket file
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | #45277
| License | MIT
| Doc PR |
In the [commit](99b4885) was done follow changes in Traits/RedisTrait.php(188)
Old code:
```$port = $hosts[0]['port'] ?? null;```
New code:
```$port = $hosts[0]['port'] ?? 6379;```
With DSN "redis:///var/run/redis/redis.sock" raise an error:
```
Redis connection "redis:///var/run/redis/redis.sock?dbindex=5" failed: php_network_getaddresses: getaddrinfo failed: Name or service not known
```
Because phpredis doesn't allow socket connections with a port
```
(new Redis)->connect('/var/run/redis/redis.sock', 6379);
```
**Error**
```
PHP Warning: Redis::connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /root/test_redis.php on line 5
PHP Fatal error: Uncaught RedisException: php_network_getaddresses: getaddrinfo failed: Name or service not known in /root/test_redis.php:5
Stack trace:
#0 /root/test_redis.php(5): Redis->connect()
#1 {main}
thrown in /root/test_redis.php on line 5
```
I added additional validation of connection type (by host or socket). Also I fixed condition when RedisSentinel connection call as it supports connections by host only.
Commits
-------
214fdd1 [Cache] Fix connecting to Redis via a socket file
Symfony version(s) affected
v4.4.37
Description
After update from v4.4.27 to v4.4.37 symfony cache can't connect redis through the socket.
How to reproduce
Use socket connection to redis, use URL in redis config like this:
redis:///var/run/redis/redis.sock
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: