I'm trying this library and using version 2 because the application I'm working on is written for PHP 5.4 (I know...), and while the move to PHP7 is planned, it's less urgent than my need to integrate WebSockets.
After spending a lot of time on trying to make all of this work, I stumbled on a weird issue where the script crashed because of this:
warning: Wrench\ConnectionManager: Wrong input arguments: exception 'InvalidArgumentException' with message 'Invalid request line'
The stack trace below this message showed that the onData method was called with the string "G" as the $data argument. I noticed the cause of this was that the Socket::receive() method returned prematurely because of the 'unread_bytes' value of $metadata being equal to 0 at that point.
Not knowing much about this, but reading in the PHP documentation for stream_get_meta_data() that "You shouldn't use this value in a script," I tried commenting out this whole if ($metadata && isset($metadata['unread_bytes'])) block.
And to my surprise, it worked flawlessly, at least for now. I can now connect to the server, send and receive messages.
Is that a bug, of simply me using the library the wrong way? Is this method (removing the block) a proper patch or will it likely cause other issues?
I'm trying this library and using version 2 because the application I'm working on is written for PHP 5.4 (I know...), and while the move to PHP7 is planned, it's less urgent than my need to integrate WebSockets.
After spending a lot of time on trying to make all of this work, I stumbled on a weird issue where the script crashed because of this:
warning: Wrench\ConnectionManager: Wrong input arguments: exception 'InvalidArgumentException' with message 'Invalid request line'The stack trace below this message showed that the
onDatamethod was called with the string "G" as the$dataargument. I noticed the cause of this was that theSocket::receive()method returned prematurely because of the'unread_bytes'value of$metadatabeing equal to 0 at that point.Not knowing much about this, but reading in the PHP documentation for
stream_get_meta_data()that "You shouldn't use this value in a script," I tried commenting out this wholeif ($metadata && isset($metadata['unread_bytes']))block.And to my surprise, it worked flawlessly, at least for now. I can now connect to the server, send and receive messages.
Is that a bug, of simply me using the library the wrong way? Is this method (removing the block) a proper patch or will it likely cause other issues?