The read_stream function reads just one chunk of data that must be at most RECV_BUFFER bytes long.
This breaks when a message is longer than RECV_BUFFER.
The fix is keeping on executing
data = stream.read(RECV_BUFFER)
and break if len(data) < RECV_BUFFER.
I will post a patch proposal soon.