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
This commit is contained in:
Omar Ghishan
2013-12-18 17:47:52 -08:00
parent 60ccb4dd02
commit 0f2b08d802

View File

@@ -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 == "":