# Existe-t-il un moyen de modifier le délai d'expiration de la connexion Redis ?

**URL:** https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476
**Category:** Self-hosting
**Created:** [Décembre 17, 2018, 3:53 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476 "2018-12-17T15:53:38Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Shane\_Liebling](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shane_liebling/32/127049_2.png) [@Shane\_Liebling](https://meta.discourse.org/u/Shane_Liebling)
#### Post date: [Décembre 17, 2018, 3:53 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/1 "2018-12-17T15:53:38Z")

</div>

I keep getting timeouts from redis/hiredis and would like to increase the timeout to see if it fixes the issue. (I am connecting to a remote redis instance, not on the same instance as Discourse.)

Additionally I need to turn off CLIENT operations as well. Afaict both of these would be done in a redis.config{} stanza but I’d prefer not to have to go in and patch the code.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [Décembre 17, 2018, 4:11 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/2 "2018-12-17T16:11:49Z")

</div>

You can config redis using the app.yml section `Beginning of custom commands` with something like

```
  - replace:
      filename: "/etc/redis/redis.conf"
      from: "daemonize yes"
      to: ""

```

---

<div class="post-metadata">

### Author: ![Shane\_Liebling](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shane_liebling/32/127049_2.png) [@Shane\_Liebling](https://meta.discourse.org/u/Shane_Liebling)
#### Post date: [Décembre 17, 2018, 4:17 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/3 "2018-12-17T16:17:27Z")

</div>

I’m sure I am misunderstanding something here, but when I see /etc/… I assume that is happening on the vm running the redis server. Am I wrong in that reading?

I am trying to change how the Discourse rails app communicates with the remote redis instance so that it (the client side) will make those calls with a longer timeout.

Sorry if I am misunderstanding your response.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [Décembre 17, 2018, 4:52 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/4 "2018-12-17T16:52:58Z")

</div>

Oh I see now. You want to pass a new parameters here:

> <https://github.com/discourse/discourse/blob/main/app/models/global_setting.rb#L143-L154>

Sounds like an acceptable PR for me, that adds a setting to set `c[:timeout] = redis_timeout if redis_timeout`.

However, we have seen some people suffering for bad page timings when redis has a long latency to the webserver, keep that in mind.

---

<div class="post-metadata">

### Author: ![Shane\_Liebling](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shane_liebling/32/127049_2.png) [@Shane\_Liebling](https://meta.discourse.org/u/Shane_Liebling)
#### Post date: [Décembre 17, 2018, 5:01 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/5 "2018-12-17T17:01:41Z")

</div>

Would setting no CLIENT ops here too be viable? (eg “id = nil”)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [Décembre 18, 2018, 3:46 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/6 "2018-12-18T15:46:27Z")

</div>

I’m not familiar with restricting the `CLIENT` ops, can you share more about your use case and why is this necessary?

---

<div class="post-metadata">

### Author: ![Shane\_Liebling](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shane_liebling/32/127049_2.png) [@Shane\_Liebling](https://meta.discourse.org/u/Shane_Liebling)
#### Post date: [Décembre 19, 2018, 2:03 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/7 "2018-12-19T14:03:50Z")

</div>

Some Redis setups (specifically cloud providers) do not allow the CLIENT operation. You can prevent this from occurring by setting “id = nil” in the redis configuration. This is an issue I have run into with sidekiq.

Other apps that use sidekiq have noted this as an issue:  
[https://github.com/mperham/sidekiq/issues/3518](https://github.com/mperham/sidekiq/issues/3518)  
[https://github.com/tootsuite/mastodon/issues/7785](https://github.com/tootsuite/mastodon/issues/7785)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [Décembre 19, 2018, 2:41 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/8 "2018-12-19T14:41:54Z")

</div>

> [@Shane\_Liebling](#):
>
> Some Redis setups (specifically cloud providers) do not allow the CLIENT operation.

I don’t think we ever hit this in AWS Elasticache offering, and also didn’t hear anything from colleagues working with Azure. What is the cloud provider that is failing for you?

---

<div class="post-metadata">

### Author: ![Shane\_Liebling](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shane_liebling/32/127049_2.png) [@Shane\_Liebling](https://meta.discourse.org/u/Shane_Liebling)
#### Post date: [Décembre 19, 2018, 8:26 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/9 "2018-12-19T20:26:23Z")

</div>

Running against Google Cloud’s Memorystore.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [Décembre 19, 2018, 8:54 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/10 "2018-12-19T20:54:54Z")

</div>

Oh that is interesting to know.

A PR to allow setting custom `REDIS_CLIENT_ID` and `REDIS_TIMEOUT`, with current values as defaults sounds a good idea.

---

<div class="post-metadata">

### Author: ![Shane\_Liebling](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shane_liebling/32/127049_2.png) [@Shane\_Liebling](https://meta.discourse.org/u/Shane_Liebling)
#### Post date: [Décembre 21, 2018, 2:23 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/11 "2018-12-21T02:23:19Z")

</div>

So if you look at [https://github.com/discourse/discourse/compare/master...shanel:master](https://github.com/discourse/discourse/compare/master...shanel:master) you’ll see the necessary edit for the client id. (Turns out that is the only one I needed.)

Unfortunately I am currently not allowed by my job to sign your release form. I could try to get my SVP to okay it, but I would bet it would take a month or two. ☹

Would you be willing/able to apply the patch?

---

<div class="post-metadata">

### Author: ![Justin\_Domingus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin_domingus/32/127766_2.png) [@Justin\_Domingus](https://meta.discourse.org/u/Justin_Domingus)
#### Post date: [Décembre 31, 2018, 3:18 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/12 "2018-12-31T15:18:02Z")

</div>

We have this same issue when trying to use Google Memorystore for redis. If you like, I can make the PR from my account. Would you like me to add you as a co-author or would that complicate the release form for you @Shane_Liebling? Here is the diff: [https://github.com/discourse/discourse/compare/master...domingusj:master](https://github.com/discourse/discourse/compare/master...domingusj:master)

If that looks correct I can submit the PR.

---

<div class="post-metadata">

### Author: ![Shane\_Liebling](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shane_liebling/32/127049_2.png) [@Shane\_Liebling](https://meta.discourse.org/u/Shane_Liebling)
#### Post date: [Décembre 31, 2018, 4:42 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/13 "2018-12-31T16:42:07Z")

</div>

No co authorship please. Thanks!

---

<div class="post-metadata">

### Author: ![Justin\_Domingus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin_domingus/32/127766_2.png) [@Justin\_Domingus](https://meta.discourse.org/u/Justin_Domingus)
#### Post date: [Décembre 31, 2018, 4:50 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/14 "2018-12-31T16:50:35Z")

</div>

Cool, all done: [Adding a setting for redis client id by domingusj · Pull Request #6837 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/6837)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [Janvier 4, 2019, 4:09 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/15 "2019-01-04T04:09:22Z")

</div>

This is tricky, I was going to force this into a plugin cause it is so rare, but we can not hook early enough.

Feature is added to core per:

[https://review.discourse.org/t/feature-add-setting-to-bypass-sending-redis-client-commands/966](https://review.discourse.org/t/feature-add-setting-to-bypass-sending-redis-client-commands/966)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [Février 13, 2021, 5:45 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-the-redis-connection-timeout/104476/16 "2021-02-13T05:45:36Z")

</div>

Un message a été divisé en un nouveau sujet : [Utilisation de Redis géré par Digital Ocean avec Discourse](https://meta.discourse.org/t/using-digital-ocean-managed-redis-with-discourse/179546)
