Skip to content

Timeout writing to socket when using redis-py with configured timeouts and health check #3741

@sandeepk97

Description

@sandeepk97

I’m seeing intermittent TimeoutError: Timeout writing to socket when using redis-py despite setting custom timeout values and health checks.

import redis
from redis.retry import Retry
from redis.backoff import ExponentialBackoff

client = redis.Redis(
    host="my-redis-host",
    port=6379,
    socket_connect_timeout=15,
    socket_timeout=5,
    socket_keepalive=True,
    retry=Retry(ExponentialBackoff(cap=10, base=1), 25),
    retry_on_error=[ConnectionError, TimeoutError, ConnectionResetError],
    health_check_interval=5,
)

client.set("foo", "bar")  # fails here

Observed behavior

Connection succeeds sometimes.

Some requests fail with:

Timeout writing to socket

Expected behavior
With the above retry/backoff + timeouts, I expect the client to automatically handle transient network issues instead of failing with write socket timeouts.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions