Skip to content

Commit 0f2b08d

Browse files
committed
Read the correct number of bytes from kafka.
According to the protocol documentation, the 4 byte integer at the beginning of a response represents the size of the payload only, not including those bytes. See http://goo.gl/rg5uom
1 parent 60ccb4d commit 0f2b08d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

kafka/conn.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,11 @@ def _consume_response_iter(self):
5555
self._raise_connection_error()
5656
(size,) = struct.unpack('>i', resp)
5757

58-
messagesize = size - 4
59-
log.debug("About to read %d bytes from Kafka", messagesize)
58+
log.debug("About to read %d bytes from Kafka", size)
6059

6160
# Read the remainder of the response
6261
total = 0
63-
while total < messagesize:
62+
while total < size:
6463
resp = self._sock.recv(self.bufsize)
6564
log.debug("Read %d bytes from Kafka", len(resp))
6665
if resp == "":

0 commit comments

Comments
 (0)