The algorithm for determining the size of MessagePack messages was wrong. The size is not encoded in the msgpack format, but distributed over the first few bytes (until the first one with the 0x80 bit set).
For messages smaller than 128 bytes, this doesn't make a difference, but for larger messages, the function failed.
I took the implementation from the official JS client and ported it to python.
The algorithm for determining the size of MessagePack messages was wrong. The size is not encoded in the msgpack format, but distributed over the first few bytes (until the first one with the 0x80 bit set). For messages smaller than 128 bytes, this doesn't make a difference, but for larger messages, the function failed. I took the implementation from the official JS client and ported it to python.