voryx / Thruway

PHP Client and Router Library for Autobahn and WAMP (Web Application Messaging Protocol) for Real-Time Application Messaging
MIT License
676 stars 118 forks source link

Consuming from the end of pubSub #264

Closed skecskes closed 7 years ago

skecskes commented 7 years ago

Hi,

I'm using the client from your example to receive messages from websocket server.

`class WebsocketConsumer {

private $client;

protected $ws_url = "wss://api.server.com";

public function __construct()
{
    $this->client = new Client("realm1");
    $this->client->addTransportProvider(new PawlTransportProvider($this->ws_url));
}

public function consumeTopic(string $topic, callable $closure) {
    $this->client->on('open', function (ClientSession $session) use ($topic, $closure) {
        $session->subscribe($topic, $closure);
    });
    $this->client->start();
}

}`

It works fine first time, because it reads the latest messages from the websocket. The next day, when I turn it on, it reads like 12 hours old messages. First I thought it will catch up with the messages which it missed and after some time read the latest messages. The problem is that even after 2-3 hours, it is still reading old messages.

Is there a way to tell to publisher, that on next day reconnect I want to receive only latest messages? Thank you for any help.

skecskes commented 7 years ago

I tested it in another websocket php client and 2 more js clients and with same old messages. I assume the websocket server or router I consume is overwhelmed with messages and consumers. I think there is no issue with this library and this issue can be closed.