Skip to content

Commit 604c588

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 f79344c commit 604c588

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
@@ -58,12 +58,11 @@ def _consume_response_iter(self):
5858
self._raise_connection_error()
5959
(size,) = struct.unpack('>i', resp)
6060

61-
messagesize = size - 4
62-
log.debug("About to read %d bytes from Kafka", messagesize)
61+
log.debug("About to read %d bytes from Kafka", size)
6362

6463
# Read the remainder of the response
6564
total = 0
66-
while total < messagesize:
65+
while total < size:
6766
resp = self._sock.recv(self.bufsize)
6867
log.debug("Read %d bytes from Kafka", len(resp))
6968
if resp == "":

0 commit comments

Comments
 (0)