Skip to content

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

@itdontgo

Description

@itdontgo

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)) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions