summaryrefslogtreecommitdiff
path: root/kafka/conn.py
diff options
context:
space:
mode:
authorOmar Ghishan <omar.ghishan@rd.io>2013-12-18 17:47:52 -0800
committerOmar Ghishan <omar.ghishan@rd.io>2014-01-06 15:14:08 -0800
commit0f2b08d80217fb82860c51e05e819012f6acb521 (patch)
tree654af68542f6a391e4412b7095737a73e1b58551 /kafka/conn.py
parent60ccb4dd025ec3e3da6feb77f9797aa1da723bfa (diff)
downloadkafka-python-0f2b08d80217fb82860c51e05e819012f6acb521.tar.gz
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
Diffstat (limited to 'kafka/conn.py')
-rw-r--r--kafka/conn.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/kafka/conn.py b/kafka/conn.py
index 6dd61cc..1997804 100644
--- a/kafka/conn.py
+++ b/kafka/conn.py
@@ -55,12 +55,11 @@ class KafkaConnection(local):
self._raise_connection_error()
(size,) = struct.unpack('>i', resp)
- messagesize = size - 4
- log.debug("About to read %d bytes from Kafka", messagesize)
+ log.debug("About to read %d bytes from Kafka", size)
# Read the remainder of the response
total = 0
- while total < messagesize:
+ while total < size:
resp = self._sock.recv(self.bufsize)
log.debug("Read %d bytes from Kafka", len(resp))
if resp == "":