Php redis connect error

Saved searches

Use saved searches to filter your results more quickly

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.

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

Cannot connect to redis socket, PHP 7 #809

Cannot connect to redis socket, PHP 7 #809

Comments

phpredis: 2.2.8-devphp7
redis: 3.2.0
PHP: 7.0.4

/tmp/redis.sock with 777 perms exists. I can connect to it with redis-cli -s /tmp/redis.sock .

$client = new \Redis(); $result = $client->connect('/tmp/redis.sock'); var_dump($result); 

The text was updated successfully, but these errors were encountered:

I’m using Arch Linux. Just did full system upgrade, and now I have PHP 7.0.6 . Problem still persists. Could I provide you with more data? I don’t know what else would you like to know. I’m using this AUR: https://aur.archlinux.org/packages/php-redis-git/ which basically is pulling and compiling code directly from the GitHub.

Читайте также:  Python numpy array stack

Connecting through TCP works just fine, problem is only with the socket.

I had same issues (similar setup, but centos 7, php 7.04, nginx, php-fpm — fine through tcp, no go with sock ). Tried different permissions on /tmp folder and as well socket file, didn’t help, but maybe I’ve missed something there. What worked for me was changing the location from ‘/tmp/redis.sock’ to other folder. Another thing was that is_file ran from php code would show false for the socket file in /tmp/redis.sock, but was ok when sock file was in other folder. Previous 2 makes me think it was a permissions issues on /tmp folder/files.

@TomSta, is a selinux enabled in your system?

I am having a similar if not same problem. I am not running SELinux. This is Arch Linux running on a raspberry pi. My socket is on /tmp/redis.sock. I have redis setup with ‘port 0’ to turn off tcp.
srwxrwxrwx 1 http http 0 Apr 13 19:10 redis.sock
In my config.php file I have
$redis->pconnect(‘/tmp/redis.sock’);
When I acces it from the browser I get:
Warning: Redis::pconnect(): connect() failed: No such file or directory in /srv/http/app/config/config.php on line 48 Fatal error: Uncaught exception ‘RedisException’ with message ‘Redis server went away’ in /srv/http/app/config/config.php:49 Stack trace: #0 /srv/http/app/config/config.php(49): Redis->get(‘dev’) #1 /srv/http/index.php(35): include(‘/srv/http/app/c. ‘) #2 thrown in /srv/http/app/config/config.php on line 49
If I change it to be
$redis->pconnect(‘127.0.0.1’);
It connects and works fine. redis and http are in each other’s groups. I do not have any open_basedir set in my php.ini file. I can connect to it as http user.

sudo -u http bash [http@deskrune root]$ whoami http [http@deskrune root]$ redis-cli -s /tmp/redis.sock redis /tmp/redis.sock> keys "*" 1) "key_0" 2) "key_1" . redis /tmp/redis.sock> exit 

Is this a bug or do I have something incorrectly set up?

I have redis setup with ‘port 0’ to turn off tcp.
If I change it to be $redis->pconnect(‘127.0.0.1’); It connects and works fine.

@gearhead, are you sure? tcp is off, how can you connect to 127.0.0.1?

@lukasz-zaroda, try the latest version of phpredis

[ excerpt ]
You can’t place sockets intended for interprocess communication in /tmp.
For security reasons, recent versions of Fedora use namespaced temporary directories, meaning every service sees a completely different /tmp and can only see its own files in that directory.
To resolve the issue, place the socket in a different directory, such as /run (formerly known as /var/run).
( but /run is not writable directly, you can instruct systemd to create a directory under it which is writable by both processes )

I did not write back, but was able to resolve my issue by this exact method. I moved redis.sock from /tmp to /run and all functionality was restored.

Источник

Saved searches

Use saved searches to filter your results more quickly

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.

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

Improve connection error #1273

Improve connection error #1273

Comments

connect() returns false if a connection could not be established and triggers a php warning. Seems like the only way to actually get the connection error message is by adding an error handler around the connection statement and capturing the php warning. I think it would make sense to create a method/property similar to mysqli::connect_error/mysqli_connect_error(). getLastError() requires an active Redis connection — it throws an exception (Redis server went away) if there is no active connection (which there wouldn’t be).

getLastError() throwing exception after connection() failed due to connection refused:

$ php -r '$r = new Redis(); try < if (!$r->connect("127.0.0.1", 1000)) echo $r->getLastError(); > catch (Exception $e) < echo "Exception: " . $e->getMessage() . "\n"; >' PHP Warning: Redis::connect(): connect() failed: Connection refused in Command line code on line 1 Exception: Redis server went away 

DNS issue actually produces two PHP warnings for me:

$ php -r '$r = new Redis(); if (!$r->connect("example.example")) echo "Some failure\n";' PHP Warning: Redis::connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in Command line code on line 1 PHP Warning: Redis::connect(): connect() failed: php_network_getaddresses: getaddrinfo failed: Name or service not known in Command line code on line 1 Some failure 

Connection timeout produces warning:

$ php -r '$r = new Redis(); if (!$r->connect("1.1.1.0")) echo "Some failure\n";' PHP Warning: Redis::connect(): connect() failed: Connection timed out in Command line code on line 1 Some failure 

I’m seeing this behaviour on

The text was updated successfully, but these errors were encountered:

Источник

Saved searches

Use saved searches to filter your results more quickly

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.

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

‘read error on connection’ #492

‘read error on connection’ #492

Comments

Hi, how can solve this error?
PHP message: PHP Fatal error: Uncaught exception ‘RedisException’ with message ‘read error on connection’
i’m getting it for this call: Redis->hGet(‘fechainicio’, ‘1’)

My system is:
PHP Version 5.4.4-14+
in phpinfo redis version 2.2.5 but in redis-cli redis_version:2.6.17
with 17 clients connected, take 6 seconds to show the command prompt when type redis-cli

Memory
used_memory:91931192
used_memory_human:87.67M
used_memory_rss:105947136
used_memory_peak:5178554456
used_memory_peak_human:4.82G
used_memory_lua:31744
mem_fragmentation_ratio:1.15
mem_allocator:jemalloc-3.2.0

The text was updated successfully, but these errors were encountered:

min: 1, max: 4762, avg: 580.68 (81 samples)

To me this looks like a timeout failure. A max latency of 4762ms is quite high, average 580 is also quite high. Is the server under tremendous load or paging to disk?

The server only has 3k http requests per minute, the 99% of their has this schema:
nginx=>php=>echo get content from redis, some atomic increment in redis
the other 1% of requests call to database and store result in redis
Server has 64gb of ram
About paging to disk, if refer to save redis to disk, i have disable it, if no refer to it, explain it please
Thanks

It’s difficult for me to diagnose the problem without knowing more information. These latency numbers are really, really high:

min: 1, max: 4762, avg: 580.68 (81 samples)

Here is a random production server we use, which is under constant load (>50k ops/sec):

min: 0, max: 4, avg: 0.69 (898 samples)

The most likely possibilities:

  1. You have a network issue. You could test that by running —latency on the server itself (assuming you didn’t).
  2. You have operations that are incredibly expensive (e.g. KEYS, ZUNIONSTORE on huge sets, etc)
  3. The server is out of ram and paging. Honestly though, Redis is still generally fast in this case as long as you aren’t doing expensive ops.

Tell me what more info need
network issue: the test was did in localhost
operations: i only use: hget, hset, lpop, and hincr
The redis is set with 100 mb of memory

I’m happy to try and help, but this doesn’t appear to be related to phpredis at all. 😄

Could you send me the output from 👍

redis info
and
slowlog get 10

This is the data of redis-info, the server is recently restarted, i’m also getting high cpu usage in the php pool that call to redis.
Slow log return empty list

Server

redis_version:2.6.17
redis_git_sha1:00000000
redis_git_dirty:0
redis_mode:standalone
os:Linux 3.10.23-xxxx-std-ipv6-64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.7.2
process_id:5107
run_id:74a23fe027297315ab832f7483326d057f29785b
tcp_port:6379
uptime_in_seconds:406
uptime_in_days:0
hz:10
lru_clock:218698

Clients

connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

Memory

used_memory:47619360
used_memory_human:45.41M
used_memory_rss:49885184
used_memory_peak:5178553432
used_memory_peak_human:4.82G
used_memory_lua:31744
mem_fragmentation_ratio:1.05
mem_allocator:jemalloc-3.2.0

Persistence

loading:0
rdb_changes_since_last_save:195548
rdb_bgsave_in_progress:0
rdb_last_save_time:1407278415
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok

Stats

total_connections_received:39364
total_commands_processed:313049
instantaneous_ops_per_sec:1053
rejected_connections:0
expired_keys:0
evicted_keys:764
keyspace_hits:0
keyspace_misses:78610
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0

Replication

used_cpu_sys:10.82
used_cpu_user:25.61
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

Источник

Оцените статью