{"record":{"id":"f8448bf03359ff07","repo":"redis/jedis","slug":"failed-to-read-pending-buffer-for-push-messages","errorCode":null,"errorMessage":"Failed to read pending buffer for push messages!","messagePattern":"Failed to read pending buffer for push messages!","errorType":"exception","errorClass":"JedisConnectionException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/Protocol.java","lineNumber":314,"sourceCode":"  @Experimental\n  public static Object read(final RedisInputStream is, PushConsumerChain pushConsumer) {\n    return process(is, pushConsumer);\n  }\n\n  @Experimental\n  public static Object readPushes(final RedisInputStream is, final PushConsumerChain pushConsumer) {\n    Object unhandledPush = null;\n      try {\n        while (unhandledPush == null && is.available() > 0 && is.peek(GREATER_THAN_BYTE)) {\n          is.readByte();\n          PushMessage message = processPush(is, pushConsumer);\n          if (message != null) {\n            unhandledPush = message.getContent();\n          }\n\n        }\n      } catch (IOException e) {\n        throw new JedisConnectionException(\"Failed to read pending buffer for push messages!\", e);\n      }\n    return unhandledPush;\n  }\n\n  private static PushMessage processPush(final RedisInputStream is, PushConsumerChain consumer) {\n    List<Object> list = processMultiBulkReply(is);\n    return consumer.process(new PushMessage(list));\n  }\n\n  public static final byte[] toByteArray(final boolean value) {\n    return value ? BYTES_TRUE : BYTES_FALSE;\n  }\n\n  public static final byte[] toByteArray(final int value) {\n    return SafeEncoder.encode(String.valueOf(value));\n  }\n\n  public static final byte[] toByteArray(final long value) {","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/Protocol.java#L296-L332","documentation":"Protocol.readPushes wraps IOExceptions raised while draining buffered RESP3 push messages (pub/sub, invalidation, etc.) in JedisConnectionException with the message \"Failed to read pending buffer for push messages!\". The underlying socket failed while reading pending push data.","triggerScenarios":"An RESP3 connection used by a push consumer (pub/sub subscriber, client-side caching) whose socket is closed or reset while readPushes drains the buffer.","commonSituations":"Network drop or server restart during an active subscription; firewall/NAT killing long-lived idle subscriber connections; SSL handshake failure on reconnect.","solutions":["Catch JedisConnectionException and resubscribe (re-run subscribe/psubscribe) on a new connection.","Verify network stability and firewall idle-timeout settings for long-lived connections.","Enable SSL/TLS correctly if the endpoint requires it (an SSL error surfaces as this IOException).","Check Redis server logs for restarts or client-kill events."],"exampleFix":"// before\njedis.subscribe(listener, \"channel\"); // dies on network blip\n\n// after\nwhile (true) {\n  try (Jedis j = pool.getResource()) {\n    j.subscribe(listener, \"channel\");\n  } catch (JedisConnectionException e) {\n    listener.reconnect(); // clear subscribed state, then loop and resubscribe\n    sleep(backoff);\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  jedis.subscribe(listener, \"channel\");\n} catch (JedisConnectionException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"push messages\")) {\n    // reconnect and resubscribe with backoff\n    Thread.sleep(backoffMillis);\n    resubscribe(listener, \"channel\");\n  } else {\n    throw e;\n  }\n}","preventionTips":["Always wrap long-lived subscribers in a reconnect/resubscribe loop.","Keep subscriber connections active; beware NAT/firewall idle timeouts.","Use RESP3 only when the server and network path support it stably.","Monitor connection errors to distinguish network flaps from server restarts."],"tags":["network","pubsub","resp3","push-messages","connection"],"backgroundTag":"network-request-failed","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}