Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bug fix for socket connection to a server with a specified port #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

alebedev80
Copy link
Contributor

In the commit 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). I fixed condition when RedisSentinel connection call as it support connections by host only.

@symfony-bot
Copy link

symfony-bot bot commented Feb 2, 2022

Thanks for your pull request! We love contributions.

However, this repository is what we call a "subtree split": a read-only copy of one directory of the main Symfony repository. It is used by Composer to allow developers to depend on specific Symfony components.

If you want to contribute, you should instead open a pull request on the main repository:

https://github.com/symfony/symfony

Thank you for your contribution!

PS: if you haven't already, please add tests, and beware that bug fixes should be submitted on the lowest maintained branch where they apply.


return $hosts;
}
private static $defaultConnectionOptions = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep the original indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants