A
A
Andrey Suha2019-08-16 11:47:56
Laravel
Andrey Suha, 2019-08-16 11:47:56

Why is laraver-echo-server not returning an event to the browser?

I'm trying to make real-time chat. Installed redis and laravel-echo-server.
Here are echo server configs

{
  "authHost": "http://hobby.website.local",
  "authEndpoint": "/broadcasting/auth",
  "clients": [
    {
      "appId": "id",
      "key": "key"
    }
  ],
  "database": "redis",
  "databaseConfig": {
        "redis": {
            "host": "127.0.0.1",
            "port": "6379",
            "db": 0
        },
    "sqlite": {
      "databasePath": "/database/laravel-echo-server.sqlite"
    }
  },
  "devMode": true,
  "host": "hobby.website.local",
  "port": "6001",
  "protocol": "http",
  "socketio": {},
  "secureOptions": 67108864,
  "sslCertPath": "",
  "sslKeyPath": "",
  "sslCertChainPath": "",
  "sslPassphrase": "",
  "subscribers": {
    "http": true,
    "redis": true
  },
  "apiOriginAllow": {
    "allowCors": false,
    "allowOrigin": "",
    "allowMethods": "",
    "allowHeaders": ""
  }

next set horizon to handle queue, specified redis queue handler in .env and BROADCAST_DRIVER in redis.
Created an event
class MessageToPrivateTree implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    private $treeId;
    public $msg;

    public function __construct(Int $treeId, $msg) {
        $this->treeId = $treeId;
        $this->msg = $msg;
    }

    public function broadcastOn()
    {
        return new PresenceChannel('chat.private.' . $this->treeId);
    }
}

and listen to it like this
this.treeChannel = Socket.join(`chat.private.${chat.id}`);
this.treeChannel.here((users) => dl.log("users in chat:", users));
this.treeChannel.joining((user) => dl.log("New user join:", user));
this.treeChannel.leaving((user) => dl.log("User leave:", user));
this.treeChannel.listen("MessageToPrivateTree", (e) => dl.log(e, "ex"));

everything works fine
, here the echo server
5d566ca179a9d710072642.png
here, joining and leaving logs print messages to the console, but as soon as listen needs to be processed, nothing happens, it also does not come to the Network. How to overcome it?
Laravel 5.8
laravel echo server 1.5.6
redis-server 3.0.6

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Suha, 2019-08-16
@andreysuha

And so I have everything set up correctly and working correctly. The problem turned out to be in Laravel 5.8 itself. I found a workaround here , setting the redis prefix to ""

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question