There's a bug in the payload processing if you receive a message larger than the internal buffer size (4K). You need to move the doread down so that it keeps on reading (with state == Payload) until the entire message is processed and remaininglength == 0. Currently you only call do_read if reaminginglength == 0 on the first read and message fits in the buffer.
There's a bug in the payload processing if you receive a message larger than the internal buffer size (4K). You need to move the doread down so that it keeps on reading (with state == Payload) until the entire message is processed and remaininglength == 0. Currently you only call do_read if reaminginglength == 0 on the first read and message fits in the buffer.