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

cannot connect to a tile38 server with docker #11

Closed
Ahmed-Nasser opened this issue Jul 28, 2022 · 0 comments
Closed

cannot connect to a tile38 server with docker #11

Ahmed-Nasser opened this issue Jul 28, 2022 · 0 comments

Comments

@Ahmed-Nasser
Copy link

Ahmed-Nasser commented Jul 28, 2022

`
private $_socket;

public function __construct($address, $port)
{
    $this->_socket = stream_socket_client($address.':'.$port);
}

public function __call($method, array $args)
{
    array_unshift($args, $method);

    $cmd = '*' . count($args) . "\r\n";

    foreach ($args as $item) {
        $cmd .= '$' . strlen($item) . "\r\n" . $item . "\r\n";
    }
    fwrite($this->_socket, $cmd);

    return $this->_parseResponse();
}

private function _parseResponse()
{
    $line = fgets($this->_socket);

    list($type, $result) = array($line[0], substr($line, 1, strlen($line) - 3));

    if ($type == '-') // error message
    {
        throw new TinyRedisClient_Exception($result);
    } elseif ($type == '$') // bulk reply
    {
        if ($result == -1)
            $result = null;
        else {
            $line = fread($this->_socket, $result + 2);
            $result = substr($line, 0, strlen($line) - 2);
        }
    } elseif ($type == '*') // multi-bulk reply
    {
        $count = ( int ) $result;
        for ($i = 0, $result = array(); $i < $count; $i++) {
            $result[] = $this->_parseResponse();
        }
    }
    return $result;
}

`
the problem here is that I don't know where the fwrite() function writes my file does it create an actual file or does it write to the stream resource I don't know, when I try this on my local machine it works fine and the command sent to my database but after I moved to docker this line $line = fgets($this->_socket); returns a false which means there is no data has been written or some error happened, I am expecting the written command to the stream

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