Skip to content

[BUG] Subscribe hangs when RESP3 and push_cb are used #1170

@zuiderkwast

Description

@zuiderkwast

Hi Michael,

When a push callback is set, redisCommand() (and friends) expect an in-band reply to each command while any push replies are dispatched to the push callback.

The problem is the [P|S][UN]SUBSCRIBE commands, because on success, they have no in-band reply. On success, they generate one or more PUSH replies. This causes redisCommand() to hang indefinitely in redisNextInBandReplyFromReader().

I raised the issue here: redis/redis#11784. It can't be fixed since it would be a breaking change, but instead we ended up improving the documentation of these commands: redis/redis-doc#2327. Now, these commands contain the following note:

When successful, this command doesn't return anything. Instead, for each channel, one message with the first element being the string "subscribe" is pushed as a confirmation that the command succeeded.

Solution?

The only solution I can think of is to check the command sent to Redis. If it ends in "subscribe" (case-insensitive), the command requires either an error reply or at least one push message (one per channel) where the first element is the name of the command in lowercase.

Workarounds

The current workaround is to unset the push callback or not use RESP3.

Metadata

Metadata

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