apache/hadoop · error · EOFException

Unexpected EOF while trying to read response from server

Error message

Unexpected EOF while trying to read response from server

What it means

PBHelperClient.vintPrefixed reads the varint length prefix that frames protobuf responses (inotify getEditsFromTxid replies, short-circuit SHM responses, encryption negotiation responses). A first read() returning -1 means the server closed the connection without sending a single byte - the response never arrived, so an EOFException is thrown.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelperClient.java:532

  public static List<StorageTypeProto> convertStorageTypes(
      StorageType[] types, int startIdx) {
    if (types == null) {
      return null;
    }
    final List<StorageTypeProto> protos = new ArrayList<>(
        types.length);
    for (int i = startIdx; i < types.length; ++i) {
      protos.add(convertStorageType(types[i]));
    }
    return protos;
  }

  public static InputStream vintPrefixed(final InputStream input)
      throws IOException {
    final int firstByte = input.read();
    if (firstByte == -1) {
      throw new EOFException(
          "Unexpected EOF while trying to read response from server");
    }

    int size = CodedInputStream.readRawVarint32(firstByte, input);
    assert size >= 0;
    return new LimitInputStream(input, size);
  }

  public static CipherOption convert(HdfsProtos.CipherOptionProto proto) {
    if (proto != null) {
      CipherSuite suite = null;
      if (proto.getSuite() != null) {
        suite = convert(proto.getSuite());
      }
      byte[] inKey = null;
      if (proto.getInKey() != null) {
        inKey = proto.getInKey().toByteArray();
      }

View on GitHub (pinned to 2add963021)

Solutions

  1. Check whether the server process (NN/DN) is alive and inspect its logs for a crash or restart
  2. Catch EOFException, re-create the client/stream and retry from the last seen txid (inotify) or the previous request
  3. Review server-side timeouts and any network middleboxes that kill idle connections
Defensive patterns

Strategy: retry

Try / catch

long lastSeenTxid = ...; // checkpoint
try {
  batches = inotifyFetch(lastSeenTxid);
} catch (EOFException e) {
  // server closed before replying: re-create the stream, refetch from checkpoint
  stream = recreateInotifyStream();
  batches = inotifyFetch(lastSeenTxid);
}

Prevention

When it happens

Trigger: DFSInotifyEventInputStream polls getEditsFromTxid against a NameNode that died or restarted mid-poll; a DataNode closes its domain socket before answering requestShortCircuitShm; the peer drops the connection during encryption negotiation.

Common situations: NN/DN restart or OOM kill while a client waits on a long-poll; idle connections reaped by a firewall; inotify tailers that outlive a NameNode failover.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/e791f1fe5d031628. Report an issue: GitHub.