Skip to content

Add connection timeout #210

@slashmo

Description

@slashmo

For a demo I'm building I'd like to show the effect of a bad Valkey connection configuration to a server's request handling. Currently, the effect is that the requests are blocked indefinitely as it seems the connection attempt never times out.

let client = ValkeyClient(.hostname("badhost", port: 1234), logger: logger)

// blocked indefinitely
try await client.hget(ValkeyKey(userID), field: "cart")
2025-09-07T08:55:21Z [debug] cart [unknown] Creating new connection code.filepath=Valkey/ValkeyConnection+ConnectionPool.swift valkey_connection_id=0 code.lineno=76
2025-09-07T08:55:26Z [debug] cart [unknown] Connection creation failed valkey_connection_id=0 code.filepath=Valkey/ValkeyConnection+ConnectionPool.swift error=DNS error: unknown(host: "badhost", port: 1234) code.lineno=87
2025-09-07T08:55:26Z [debug] cart [unknown] Creating new connection code.filepath=Valkey/ValkeyConnection+ConnectionPool.swift valkey_connection_id=0 code.lineno=76
2025-09-07T08:55:26Z [debug] cart [unknown] Connection creation failed valkey_connection_id=0 code.filepath=Valkey/ValkeyConnection+ConnectionPool.swift error=DNS error: unknown(host: "badhost", port: 1234) code.lineno=87
# ...

Is this the desired behavior or should Valkey time out when establishing connections?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions