From 949d8efc04e37eb94f050fa1afdd8862aa592ebc Mon Sep 17 00:00:00 2001 From: ujihisa Date: Sun, 19 Jan 2020 14:44:35 -0800 Subject: [PATCH] Disable reconnecting which doubles the duration until unsubscribe * Problem: In the "Timeouts" section in README, it says "If no message is received after 5 seconds, the client will unsubscribe." but it actually unsubscribes after 10 seconds. It's because by default reconnect_attempts is 1 and the client tries subscribing for 5 seconds twice. * Solution: Explicitly set reconnect_attempts to 0 * This can be tricky for first time readers since the "Reconnections" section comes after this "Timeouts" section. * Alternative solution: change the description that it will unsubscribe after 10 seconds. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cc80496cc..82a0db6c5 100644 --- a/README.md +++ b/README.md @@ -261,6 +261,7 @@ All timeout values are specified in seconds. When using pub/sub, you can subscribe to a channel using a timeout as well: ```ruby +redis = Redis.new(reconnect_attempts: 0) redis.subscribe_with_timeout(5, "news") do |on| on.message do |channel, message| # ...