Answer the question
In order to leave comments, you need to log in
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": ""
}
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);
}
}
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"));
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question