tlaverdure / laravel-echo-server

Socket.io server for Laravel Echo
MIT License
2.64k stars 509 forks source link

echo receiving event from redis but never received in browser #553

Closed Silassiai closed 3 years ago

Silassiai commented 3 years ago

I found some answers that it could be the prefix, so i removed that in my .env with REDIS_PREFIX=""

if i do DEBUG=* laravel-echo-server start i see the message comming, but do not know what all this means. Who can help me out, is there something in this log what can help my find out where the problem is image

image

worker: image

clients setup:

        window.Echo = new Echo({
            broadcaster: 'socket.io',
            host: `server.rocketsuite:6001`,
            auth: {
                headers: {
                    Authorization: "Bearer ".concat(localStorage.getItem("access_token"))
                }
            }
        });
        // console.log("window.Echo", window.Echo);
        window.Echo.channel(`manage.campaigns.3`)
            .listen('.bla.bla', (e) => {
                console.log("listener received answer");
                console.log(e);
            }).listen('bla.bla', (e) => {
                console.log("listener received answer");
                console.log(e);
            });

backend setup:


<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class EchoTest implements ShouldBroadcastNow
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('manage.campaigns.3');
    }

    /**
     * The event's broadcast name.
     *
     * @return string
     */
    public function broadcastAs()
    {
        return 'bla.bla';
    }

    /**
     * Get the data to broadcast.
     *
     * @return array
     */
    public function broadcastWith()
    {
        return ['id' => 'asdasd'];
    }
}
Silassiai commented 3 years ago

Found the issue, our frontend guy used socket.io instead of socket.io-client in the package.sjon