-
-
Notifications
You must be signed in to change notification settings - Fork 986
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
Error while reading line from the server #33
Comments
Have you already followed the steps described here to debug your issue before opening a new issue with the very same title? See also this thread on the Redis list, it might also be something unrelated to client-side issues. |
Thank you nrk. I will try setting the socket_timeout and read_write_timeout and report my findings here later. |
If you are using Predis in a daemon-like script you should set |
nrk, tried as mentioned and it's now working perfectly. Thank you! However, there's still a lot of connection timeouts now and then. I've already set timeout = 0 and read_write_timeout to -1. Is there anything that we can do to debug this when it occurs? |
I'll leave this issue open for now, but I'm quite sure it's definitely not something related to Predis. |
nrk. As advised, I've raised connection_timeout to 30. Will be monitoring this.
|
Another update, I measured the connection, and it appears that indeed the exception occured after 5s. I tried modifying the connection_timeout via: new Predis_Client($param, array('read_write_timeout' => -1, 'connection_timeout' => 30)); Is that correct? It doesn't seems to take effect the 30s connection_timeout and still throw exception. |
They are connection parameters and not client options, so
Honestly, Predis doesn't do anything fancy with the socket resources when connecting to a host since it's something delegated almost entirely to PHP's internals, so it can be either a bug in PHP (unlikely, but still a possibility) or some configuration/runtime issue on your servers, or Redis doing some heavy operations that end up blocking the server for a while. |
nrk, thank you again for your reply. I found the problem, and it's just the server running out of ip_conntrack issue. Once the conntrack is fixed, the connection timeout goes away as well. |
Nice to know that you have finally found the actual problem behind those timeouts. I will probably add this somewhere in the FAQ to give users an initial list of checks for troubleshooting timeout issues. |
was getting the same error, solved using setting read_write_timeout as 0. |
@amitchhajer the client accepts the same connection parameters with both named arrays or URI strings, so if you are using an URI string you can just add it as if it were a query string: |
@nrk thanks for the info, works pretty well now. |
What if we need to change read_write_timeout at runtime? Is some setter for timeout params (except constructor) exists? |
@bondeg connection parameters are intentionally immutable which means you can't change them once the connection has been initialized, but you can work around this limitation by fetching the underlying stream resource from the connection object used by the client and change the stream options accordingly. Here is a small snippet, assuming you are not using the client in cluster or replication mode: $connection = $client->getConnection();
$stream = $connection->getResource();
stream_set_timeout($stream, 2); Please note that doing |
Please notice that the parameter |
I'm using 'hkeys' pretty extensively. Can this lead to locks? |
Any drawback or caution associated with setting timeout=0 at redis.conf ? What I suspect is ..as connections will never drop |
How to fix this contract.. where to look for ? |
@aditya-rewari-cb actually |
@nrk I am using Redis with daemon proceses (laravel supervisor workers), as well as , with regular caching Thanks ! |
@aditya-rewari-cb I have a same problem. You found a solution for it? |
I have vague memory of this now! |
This should fix Redis connection timeouts during long-running jobs. See predis/predis#33 (comment) Bug: T349719 Change-Id: I272559e7ff5ca5a7e753da62a8e43c24281781be
Using redis for php 5.2 branch. I'm getting random "Error while reading line from the server" error. The command i used is lpush a serialized string.
I'm using predis on a php daemon script, meaning it's up all the time. I've already set the timeout for redis.conf to 0.
The text was updated successfully, but these errors were encountered: