ratchetphp/RFC6455

Blocking operations in message handler can break MessageBuffer

Closed this issue · 0 comments

jmoo commented

onData can receive another frame before $onMessage completes and $this->messageBuffer gets null'd out, corrupting the messageBuffer.

MessageBuffer.php:99

if ($this->messageBuffer->isCoalesced()) {
    $msgCheck = $this->checkMessage($this->messageBuffer);
    if (true !== $msgCheck) {
        $onControl($this->newCloseFrame($msgCheck, 'Ratchet detected an invalid UTF-8 payload'));
    } else {
        $onMessage($this->messageBuffer);
    }

    $this->messageBuffer = null;

...