repejota / phpnats

A PHP client for the NATSio cloud messaging system.

Home Page:http://nats.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nats 1.1.0 Undefined index: ssl_required

RustamDR opened this issue · comments

I'm trying to connect to nats: 1.1.0 and Exception occures:
/var/www/api/vendor/repejota/nats/src/Nats/ServerInfo.php on line 106
Undefined index: ssl_required

This is because of ServerInfo tries to get 'ssl_required' from response data array, but there is not this field already.
INFO {"server_id":"NoABA0dKfQ5MHXHZBgpCqB","version":"1.1.0","git_commit":"add6d79","go":"go1.9.4","host":"0.0.0.0","port":4222,"auth_required":false,"tls_required":false,"tls_verify":false,"max_payload":1048576}

but the previous nats version 1.0.6 had it:

INFO {"server_id":"yMuJO0GoePqmnzQwYxztDN","version":"1.0.6","git_commit":"02dd205","go":"go1.9.4","host":"0.0.0.0","port":4222,"auth_required":false,"ssl_required":false,"tls_required":false,"tls_verify":false,"max_payload":1048576}

Fields aren't checked for existence:
public function __construct($connectionResponse)
{
$parts = explode(' ', $connectionResponse);
$data = json_decode($parts[1], true);

    $this->setServerID($data['server_id']);
    $this->setHost($data['host']);
    $this->setPort($data['port']);
    $this->setVersion($data['version']);
    $this->setGoVersion($data['go']);
    $this->setAuthRequired($data['auth_required']);
    $this->setSSLRequired(**$data['ssl_required']**);
    $this->setTLSRequired($data['tls_required']);
    $this->setTLSVerify($data['tls_verify']);
    $this->setMaxPayload($data['max_payload']);
}

Solved #115