Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninitialized string offset: 0 in xxx on line (209) #140

Open
itdontgo opened this issue Nov 21, 2022 · 0 comments
Open

Uninitialized string offset: 0 in xxx on line (209) #140

itdontgo opened this issue Nov 21, 2022 · 0 comments

Comments

@itdontgo
Copy link

itdontgo commented Nov 21, 2022

Occasionally when the server is under load you will get this error. Obviously the fread is returning a blank string and you should return false if it's blank. The connection has failed anyway. It's probably because it's not blocking and it's just chance that there is data to return when you do the read hence the intermittent failure.
We have set the stream to blocking and left a 5s timeout. I'll update if this resolves the issue but even if not... return false on any operation to the socket/read/write during connection.
It's probably a problem more on Windows servers as you can't rely on querying the socket.

    if(!stream_set_timeout($this->socket, 5)){return false;}
    if(!stream_set_blocking($this->socket, 1)){return false;} //blocking

To avoid the error we added 'if's:

	if(!fwrite($this->socket, $head, 2)){return false;}
	if(!fwrite($this->socket, $buffer)){return false;}

    $string = $this->read(4);
	if(!$string){return false;}

error here if (ord($string[0]) >> 4 === 2 && $string[3] === chr(0)) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant