Laravel5.2 broadcaster cannot broadcast without error?

  node.js, question

Environment: Mac, laravel Version 5.2.x, valet

Problem description:

Error occurred when using laravel to cooperate with nodeJS to make websocket.

This is the socket server code

var http = require('http').Server();
 var io = require('')(http);
 var Redis = require('ioredis');
 var redis = new Redis();
 redis.on('message', function (channel, message) {
 message = JSON.parse(message);
 Io.emit(channel plus':' plus message.event,;
 http.listen(3001, function () {
 console.log('Server is running at 3001!'  );

This is the route code.

Route::get('/test', function () {
 $data = [
 'event' => 'inbox',
 'data' => [
 'name' => 'WTF'
 Redis::publish('test-channel', json_encode($data));
 return 'Done';

After accessing the /test page, the command line displays as follows:


The front-end has also received the data and will not show it. The crux of the problem lies in

When I changed the code of route to read as follows:

Route::get('/test', function () {
 event(new \App\Events\Test('ARE U OK ?'  ));
 return 'Done';

Then through

php artisan make:event Test

The generated event event code is as follows:

<?  php
 namespace App\Events;
 use App\Events\Event;
 use Illuminate\Queue\SerializesModels;
 use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
 class Test extends Event implements ShouldBroadcast
 use SerializesModels;
 public $name;
 public function __construct($name)
 $this->name = $name;
 public function broadcastOn()
 return ['test-channel'];

Then visit the /test page,Command line no output.

Before that, it was configured with broadcast’s driver.

Env document inside


Config’s cache has also been clear.

From the success of using Redis::publish, we can see that laravel and Redis links are successful, so what should be the problem?

Please advise the great god!

After restarting the project, copying the same code and executing normally, it was found that the problem caused by QUEUE_DRIVER=redis of the original project should be the problem of queue.

Change QUEUE_DRIVER=redis to sync.