redis/jedis · error · JedisException

Blocking pub/sub operations are not supported on…

Error message

Blocking pub/sub operations are not supported on token-based authentication enabled connections with RESP2 protocol!

What it means

JedisShardedPubSubBase.checkConnectionSuitableForPubSub() rejects blocking sharded pub/sub (SSUBSCRIBE) on connections that use token-based authentication together with the RESP2 protocol. RESP3 is required for the push/notification machinery used with token auth, so blocking on RESP2 + token auth is unsupported and throws this JedisException before subscribing.

Solutions

  1. Switch the client to RESP3 via the protocol configuration option.
  2. Disable token-based authentication (use plain password ACL auth) if RESP2 must stay.
  3. Upgrade to a Redis server/client combination where RESP3 + token auth is supported.
  4. Use non-blocking sharded pub/sub alternatives if available in your Jedis version.

Example fix

// before
RedisClient client = RedisClient.builder()
    .protocol(RedisProtocol.RESP2)
    .authTokenConfig(...)   // token auth + RESP2 -> error on ssubscribe
    .build();
// after
RedisClient client = RedisClient.builder()
    .protocol(RedisProtocol.RESP3)
    .authTokenConfig(...)
    .build();
Defensive patterns

Strategy: validation

Validate before calling

boolean canShardedSubscribe(RedisProtocol proto, boolean tokenAuth) {
  return proto == RedisProtocol.RESP3 || !tokenAuth;
}

Type guard

boolean supportsBlockingPubSub(Connection c) {
  return c.getRedisProtocol() == RedisProtocol.RESP3
      || !c.isTokenBasedAuthenticationEnabled();
}

Try / catch

try {
  pubSub.ssubscribe(jedis, channel);
} catch (JedisException e) {
  if (e.getMessage().contains("Blocking pub/sub operations are not supported")) {
    // rebuild client with RESP3 or disable token auth
  } else throw e;
}

Prevention

When it happens

Trigger: Calling ssubscribe() on a client whose connection has isTokenBasedAuthenticationEnabled() == true while getRedisProtocol() is RESP2 (or null, treated as RESP2).

Common situations: Clients configured for RESP2 (legacy default or explicit protocol(RedisProtocol.RESP2)) connecting to Redis 7+/managed Redis with token/IAM-based auth enabled.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/471499f951f02796. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/JedisShardedPubSubBase.java:47

  }

  public final void sunsubscribe() {
    sendAndFlushCommand(Command.SUNSUBSCRIBE);
  }

  public final void sunsubscribe(T... channels) {
    sendAndFlushCommand(Command.SUNSUBSCRIBE, channels);
  }

  public final void ssubscribe(T... channels) {
    checkConnectionSuitableForPubSub();
    sendAndFlushCommand(Command.SSUBSCRIBE, channels);
  }

  private void checkConnectionSuitableForPubSub() {
    if (authenticator.client.getRedisProtocol() != RedisProtocol.RESP3
        && authenticator.client.isTokenBasedAuthenticationEnabled()) {
      throw new JedisException(
          "Blocking pub/sub operations are not supported on token-based authentication enabled connections with RESP2 protocol!");
    }
  }

  public final boolean isSubscribed() {
    return subscribedChannels > 0;
  }

  public final int getSubscribedChannels() {
    return subscribedChannels;
  }

  public final void proceed(Connection client, T... channels) {
    authenticator.registerForAuthentication(client);
    authenticator.client.setTimeoutInfinite();
    authenticator.client.setActiveSubscription(true);
    try {
      ssubscribe(channels);

View on GitHub (pinned to 6dac31d4c2)