src/Db/Pgsql/PgConnection.php
private function start()
    {
        if ($this->connStatus !== static::CONNECTION_NEEDED) {
            throw new \Exception('Connection not in startable state');
        }

        $this->setConnStatus(static::CONNECTION_STARTED);

        $this->socket->connect($this->uri)->then(
            function (DuplexStreamInterface $stream) {
                $this->stream     = $stream;
                $this->setConnStatus(static::CONNECTION_MADE);

                $stream->on('close', [$this, 'onClose']);

                $stream->on('data', [$this, 'onData']);

                //  $ssl = new SSLRequest();
                //  $stream->write($ssl->encodedMessage());

                $startupParameters = $this->parameters;
                unset($startupParameters['host'], $startupParameters['port']);

                $startup = new StartupMessage();
                $startup->setParameters($startupParameters);
                $stream->write($startup->encodedMessage());
            },
            function ($e) {
                // connection error
                $this->failAllCommandsWith($e);
                $this->setConnStatus(static::CONNECTION_BAD);
                $this->emit('error', [$e]);
            }
        );
    }
private function start()
    {
        if ($this->connStatus !== static::CONNECTION_NEEDED) {
            throw new \Exception('Connection not in startable state');
        }

        $this->setConnStatus(static::CONNECTION_STARTED);

        $this->socket->connect($this->uri)->then(
            function (DuplexStreamInterface $stream) {
                $this->stream     = $stream;
                $this->setConnStatus(static::CONNECTION_MADE);

                $stream->on('close', [$this, 'onClose']);

                $stream->on('data', [$this, 'onData']);

                //  $ssl = new SSLRequest();
                //  $stream->write($ssl->encodedMessage());

                $startupParameters = $this->parameters;
                unset($startupParameters['host'], $startupParameters['port']);

                $startup = new StartupMessage();
                $startup->setParameters($startupParameters);
                $stream->write($startup->encodedMessage());
            },
            function ($e) {
                // connection error
                $this->failAllCommandsWith($e);
                $this->setConnStatus(static::CONNECTION_BAD);
                $this->emit('error', [$e]);
            }
        );
    }
Start connection
@throws \Exception