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

Method "publish" not working

krowinski opened this issue · comments

public function publish($subject, $payload)
{
    $msg = 'PUB '.$subject.' '.strlen($payload);
    $this->send($msg);
    $this->send($payload);
    $this->pubs += 1;
}

msg and payload should be send in one request.

this fix the problem

public function publish($subject, $payload)
{
    $msg = 'PUB '.$subject.' '.strlen($payload);
    $this->send($msg . "\r\n" . $payload);
    //$this->send($payload);
    $this->pubs += 1;
}

Tested on
php 5.4.39-0+deb7u2
gnatsd version 0.6.1.beta

Log

[11614] 2015/07/21 10:46:35.607341 [TRC] 127.0.0.1:54439 - cid:22 - ->> [CONNECT {"lang":"php","version":"0.0.5","verbose":true,"pedantic":false}]
[11614] 2015/07/21 10:46:35.608280 [TRC] 127.0.0.1:54439 - cid:22 - ->> [PUB foo 3]
[11614] 2015/07/21 10:46:35.611066 [DBG] 127.0.0.1:54439 - cid:22 - Client connection closed

should be

[12428] 2015/07/21 10:58:00.379975 [TRC] 127.0.0.1:56462 - cid:14 - ->> [CONNECT {"lang":"php","version":"0.0.5","verbose":true,"pedantic":false}]
[12428] 2015/07/21 10:58:00.380949 [TRC] 127.0.0.1:56462 - cid:14 - ->> [PUB foo 3]
[12428] 2015/07/21 10:58:00.380964 [TRC] 127.0.0.1:56462 - cid:14 - ->> MSG_PAYLOAD: [bar]
[12428] 2015/07/21 10:58:00.380976 [TRC] 127.0.0.1:56089 - cid:2 - <<- [MSG foo 55ae253d3dcd5 3]

Thanks mate!
Applied your patch on https://github.com/repejota/phpnats/tree/feature/15 branch.

Cheers!