S
S
Sergey2021-02-01 09:55:12
Laravel
Sergey, 2021-02-01 09:55:12

Why is laravel-echo-server not connecting to web socket?

I'm trying to connect laravel echo.
laravel-echo-server

{
  "authHost": "http://want_can.lc",
  "authEndpoint": "/broadcasting/auth",
  "clients": [],
  "database": "redis",
  "databaseConfig": {
    "redis": {
            "port": 6379,
            "host":"127.0.0.1",
            "keyPrefix":null
        },
    "sqlite": {
      "databasePath": "/database/laravel-echo-server.sqlite"
    }
  },
  "devMode": true,
  "host": null,
  "port": "6001",
  "protocol": "http",
  "socketio": {},
  "secureOptions": 67108864,
  "sslCertPath": "",
  "sslKeyPath": "",
  "sslCertChainPath": "",
  "sslPassphrase": "",
  "subscribers": {
    "http": true,
    "redis": true
  },
  "apiOriginAllow": {
    "allowCors": false,
    "allowOrigin": "",
    "allowMethods": "",
    "allowHeaders": ""
  }
}

here is bootstrap
if (typeof io !== 'undefined') {
window.Echo = new Echo({
     broadcaster: 'socket.io',
     host:window.location.hostname +":"+ '6001',
   //transports: ['websocket', 'polling', 'flashsocket'],
 });
}else{
    console.log('AAA!')
}

here is the event
<?php

namespace App\Events;
class PrivateChat implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $data;
    public $user;

    public function __construct($data,User $user)
    {
        $this->data=$data;
        $this->user=$user;
        $this->dontBroadcastToCurrentUser();
    }

    public function broadcastOn()
    {
        Message::create($this->data,$this->user);
        return new PrivateChannel('room.'.$this->data['room_id']);
    }
}

here is the controller
<?php

class MessageController
{
    public $service;

    public function __construct(ChatroomService $service)
    {
        $this->service=$service;
    }

    public function message(ChatRequest $request,User $user)
    {
        event ( new PrivateChat($request->all(), $user));
    }
}

here are the channels
Broadcast::channel('room.{room_id}', function ( $user, $room_id) {
    return $user->chatroomsCustomer->contains($room_id)||$user->chatroomsExecutor->contains($room_id);
});

I start laravel-echo-server
I start the queue I go to the page I open the console the network tab
6017a443c7ad3554348478.png
those sockets do not receive sid.
in socket-echo-server in the console we get
Channel: private-room.1
Event: App\Events\PrivateChat

this is what i get in the queue
[2021-02-01 06:50:25][RXvfnlILeDt6J2MTWAXPA9EStl1Cgi5X] Processing: App\Events\PrivateChat
[2021-02-01 06:50:25][RXvfnlILeDt6J2MTWAXPA9EStl1Cgi5X] Processed:  App\Events\PrivateChat

put stray https://chrome.google.com/webstore/detail/laravel-... it connects

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2021-02-05
@Serggalas

The problem was in the version of sockets. They are already the third version and no one has remade laravel-echo-server yet.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question