ghedipunk / PHP-Websockets

A Websockets server written in PHP.
BSD 3-Clause "New" or "Revised" License
913 stars 376 forks source link

Sometimes connection hangs, when working with mb-string extension #16

Closed ghost closed 9 years ago

ghost commented 9 years ago

I used to test the server with original php-cli.ini settings, which did not have the mb-string extension included. Then when I included the mb-string extension, the connections hang from time to time, without any obvious reasons. I found out tha the mb_strlen($payload) was made on the masked payload, which depending on the mask, causes the mb_strlen-function to be confused and return a false length, which indicates the server that it received a partial message and waits for it. I changed this line of code in function deframe, line 390 from
if ($headers['length'] > mb_strlen($payload)) { to if ($headers['length'] > mb_strlen($this->applyMask($headers,$payload))) {

Could you please check and afterwards update the code, since I am not familiar with git. Thanks Martin

ghedipunk commented 9 years ago

Patch applied. Thank you, Martin.