client does not receive data with websocket laravel echo and socket.io

0

I have set up a server with laravel-echo-server, redis and I have configured an event to be able to transmit it over websocket but it has not worked, the queue and the server transmit the data but I can not get them in the client.

Conf. laravel echo server

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

Event:

<?php

namespace notificacion\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;

class notificacionGenerada implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
 * Create a new event instance.
 *
 * @return void
 */

public $notificacionData;
public function __construct($nt)
{
    $this->notificacionData = $nt;
}

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

When creating a new record and triggering the event with the command

php artisan queue:list --tries=1

I get

[2018-06-14 02:10:45][I2dp4rt3YTR9uwFDWyloRNh1nZSStjyP] Processing: notificacion\Events\notificacionGenerada
[2018-06-14 02:10:45][I2dp4rt3YTR9uwFDWyloRNh1nZSStjyP] Processed:  notificacion\Events\notificacionGenerada

in laravel echo

Starting server...
✔  Running at 127.0.0.1 on port 6001
✔  Channels are ready.
✔  Listening for http events...
✔  Listening for redis events...
Server ready!
CHANNEL notificacion-channel

My client js (bootstrap.js)

import Echo from 'laravel-echo'
import io from "socket.io-client"
window.io = io
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'socket.io',
host: 'http://127.0.0.1:6001'
});

(app.js)

Echo.channel('notificacion-channel')
.listen('notificacionGenerada', (data) => {
    console.log(data);
})

Client who should receive websocket information

I am not using authentication, nor the csrf token, in fact I have commented in the kernel the following line in web routes

// \notificacion\Http\Middleware\VerifyCsrfToken::class,
    
asked by César Alejandro M 14.06.2018 в 04:24
source

0 answers