diff --git a/src/Server/Ratchet.php b/src/Server/Ratchet.php index 26b6f13..a1757c6 100644 --- a/src/Server/Ratchet.php +++ b/src/Server/Ratchet.php @@ -194,17 +194,6 @@ class Ratchet implements MessageComponentInterface ); } - // Check message encoding valid - else if (!mb_check_encoding($connection->message, 'UTF-8')) - { - $connection->send( - implode( - PHP_EOL, - $config->response->submit->failure->encoding - ) . PHP_EOL - ); - } - // Max length already checked on input, begin message save else { @@ -277,6 +266,19 @@ class Ratchet implements MessageComponentInterface // Complete message by new line sent $connection->message .= $request . PHP_EOL; + // Check message encoding valid + if (!mb_check_encoding($connection->message, 'UTF-8')) + { + $connection->send( + implode( + PHP_EOL, + $config->response->submit->failure->encoding + ) . PHP_EOL + ); + + $connection->close(); + } + // Check total message length limit allowed by KevaCoin protocol if (mb_strlen($connection->message) > 3074) {