正常使用沒問題。我本地壓測也沒出現(xiàn)這個錯誤。redis的騰訊云的redis 集群。
服務器上會出現(xiàn)這個錯誤。很少但是會出現(xiàn)。
參考網(wǎng)上示例。把read_write_timeout 改成了0 還是不行。想問下大大,可能是什么原因。跟workerman多進程切換有關系嗎
Predis\Connection\AbstractConnection::onConnectionError code:0 msg:Error while reading line from the server.
redis服務端有個timeout配置,是用來關閉不活躍reids連接的,設置成0試下
恩我在github看到了一個答案是說
If you are using Predis in a daemon-like script you should set read_write_timeout to -1 if you want to completely disable the timeout (this value works with older and newer versions of Predis). Also, remember that you must disable the default timeout of Redis by setting timeout = 0 in redis.conf or Redis will drop the connection of idle clients after 300 seconds of inactivity.
說如果守護進程的話使用predis的話要改成-1.
Also, remember that you must disable the default timeout of Redis by setting timeout = 0 in redis.conf
我說的是這個,redis服務端的配置
@16:這個啊我看看。這個值是用來關閉不活躍的鏈接的。如果設置為0 的話意思是不在關閉不活躍的鏈接對吧?那這樣對性能會有影響嗎。我是否可以在我每次我處理完一個請求之后我程序手動關閉當前使用的redis 鏈接?
在onWorkerStart里初始化redis,千萬不要在onWorkerStart執(zhí)行前就初始化,onWorkerStart執(zhí)行前初始化redis的redis連接屬于主進程,fork的子進程會自動繼承主進程的這個redis連接,這樣會導致多個子進程都可以對同一個redis連接進行讀寫,導致數(shù)據(jù)錯亂。
我是在
$http_worker->onWorkerStart = function($http_worker) {
// init app
App::init();
};
onWorkerStart 里初始化的單例的redis。平時不會有問題。就是請求量多的時候會報上面那個錯。