Laravel echo private channel connection


  • | 527 points

    hello friends can someone here help me for laravel echo configuration on laravel???
    here is my config

    {
    "authHost": "http://myapp.dev",
    "authEndpoint": "/broadcasting/auth",
    "clients": [],
    "database": "redis",
    "databaseConfig": {
    "redis": {},
    "sqlite": {
    "databasePath": "/database/laravel-echo-server.sqlite"
    }
    },
    "devMode": true,
    "host": "",
    "port": "6001",
    "protocol": "http",
    "socketio": {},
    "sslCertPath": "",
    "sslKeyPath": "",
    "sslCertChainPath": "",
    "sslPassphrase": "",
    "apiOriginAllow": {
    "allowCors": true,
    "allowOrigin": "",
    "allowMethods": "",
    "allowHeaders": ""
    }
    }

    when i 'm trying to log a user on the private chanel it's says me that can't be connect at myapp:80

    here my event code

    <?php

    namespace App\Events;

    use Illuminate\Broadcasting\Channel;
    use Illuminate\Queue\SerializesModels;
    use Illuminate\Broadcasting\PrivateChannel;
    use Illuminate\Broadcasting\PresenceChannel;
    use Illuminate\Foundation\Events\Dispatchable;
    use Illuminate\Broadcasting\InteractsWithSockets;
    use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
    use App\Models\Message;
    use App\User;

    /**

    • Class NewMessage

    • @package App\Events
      */
      class NewMessage implements ShouldBroadcast
      {
      use Dispatchable, InteractsWithSockets, SerializesModels;

      /**

      • @var Message

      */
      private $message;

      /**

      • Create a new event instance.
      • @return void
        */
        public function __construct(Message $message)
        {
        $this->message = $message;
        }

      /**

      • Get the channels the event should broadcast on.
      • @return \Illuminate\Broadcasting\Channel|array
        */
        public function broadcastOn()
        {
        return new PrivateChannel('App.User.' . $this->message->to_id);
        }
    /**
     * @return array
     */
    public function broadcastWith()
    {
        return [
            'message' => $this->message->load([
                'from' => function($query) {
                    $query->select('id', 'name', 'slug', 'avatar');
                }
            ])->toArray()
        ];
    }
    

    }

    Thanks...


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.