title: How to make Laravel broadcasting/websockets work with Redis Cluster
body: <p>I got a Redis Cluster server which I created by following this <a href="https://redis.io/topics/cluster-tutorial#creating-the-cluster" rel="nofollow noreferrer">tutorial</a>. </p>
  
  <p>This is what my database/config.php setup looks like (see details <a href="https://stackoverflow.com/questions/56497809/how-to-make-laravel-work-with-redis-cluster-on-aws">here</a>):</p>
  
  <pre><code>'redis' =&gt; [
      'client' =&gt; 'predis',
      'cluster' =&gt; true,
      'options' =&gt; [
          'cluster' =&gt; 'redis',
          'parameters' =&gt; [
              'host' =&gt; env('REDIS_DEFAULT_HOST', '127.0.01'),
              'password' =&gt; env('REDIS_PASSWORD', null),
              'port' =&gt; env('REDIS_DEFAULT_PORT', 6379),
              'database' =&gt; 0,
              ],
          ],
      'clusters' =&gt; [
           'default' =&gt; [
              'host' =&gt; env('REDIS_DEFAULT_HOST', '127.0.01'),
              'password' =&gt; env('REDIS_PASSWORD', null),
              'port' =&gt; env('REDIS_DEFAULT_PORT', 6379),
              'database' =&gt; 0,
          ],
          'jobs' =&gt; [
              'host' =&gt; env('REDIS_JOBS_HOST', '127.0.01'),
              'password' =&gt; env('REDIS_PASSWORD', null),
              'port' =&gt; env('REDIS_JOBS_PORT', 6379),
              'database' =&gt; 0,
          ],
          'content' =&gt; [
              'host' =&gt; env('REDIS_CONTENT_HOST', '127.0.01'),
              'password' =&gt; env('REDIS_PASSWORD', null),
              'port' =&gt; env('REDIS_CONTENT_PORT', 6379),
              'database' =&gt; 0,
          ],
          'options' =&gt; [
              'cluster' =&gt; 'redis'
          ],
      ]
  ]
  </code></pre>
  
  <p>and what my config/broadcasting.php looks like:</p>
  
  <pre><code>&lt;?php
  
  return [
  
      /*
      |--------------------------------------------------------------------------
      | Default Broadcaster
      |--------------------------------------------------------------------------
      |
      | This option controls the default broadcaster that will be used by the
      | framework when an event needs to be broadcast. You may set this to
      | any of the connections defined in the "connections" array below.
      |
      */
  
      'default' =&gt; env('BROADCAST_DRIVER', 'redis'),
  
      /*
      |--------------------------------------------------------------------------
      | Broadcast Connections
      |--------------------------------------------------------------------------
      |
      | Here you may define all of the broadcast connections that will be used
      | to broadcast events to other systems or over websockets. Samples of
      | each available type of connection are provided inside this array.
      |
      */
  
      'connections' =&gt; [
  
          'pusher' =&gt; [
              'driver' =&gt; 'pusher',
              'key' =&gt; env('PUSHER_KEY'),
              'secret' =&gt; env('PUSHER_SECRET'),
              'app_id' =&gt; env('PUSHER_APP_ID'),
          ],
  
          'redis' =&gt; [
              'driver' =&gt; 'redis',
              'connection' =&gt; 'default',
          ],
  
          'log' =&gt; [
              'driver' =&gt; 'log',
          ],
  
      ],
  
  ];
  
  </code></pre>
  
  <p>when i reach this part in my code when i want to publish an event in redis:</p>
  
  <pre><code>   // Dispatch an event indicates order status has been changed.
                  event(new OrderStatusChanged($order-&gt;id, OrderActionsConstants::INCOMPLETE_CART));
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>Cannot use 'PUBLISH' with redis-cluster.
  </code></pre>
  
  <p>with this stack trace</p>
  
  <pre><code>[2019-06-10 17:05:06] local.ERROR: 
  0 /Users/Shared/dev/php/toters-api/vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php(550): Predis\Connection\Aggregate\RedisCluster-&gt;getConnection(Object(Predis\Command\PubSubPublish)) 
  1 /Users/Shared/dev/php/toters-api/vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php(593): Predis\Connection\Aggregate\RedisCluster-&gt;retryCommandOnFailure(Object(Predis\Command\PubSubPublish), 'executeCommand') 
  2 /Users/Shared$dev/php/toters-api/vendor/predis/predis/src/Client.php(331): Predis\Connection\Aggregate\RedisCluster-&gt;executeCommand(Object(Predis\Command\PubSubPublish)) 
  3 /Users/Shared/dev/php/toters-api/vendor/predis/predis/src/Client.php(314): Pre$is\Client-&gt;executeCommand(Object(Predis\Command\PubSubPublish)) 
  4 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(72): Predis\Client-&gt;__call('publish', Array) 
  5 /Users/Shared/de$/php/toters-api/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(84): Illuminate\Redis\Connections\Connection-&gt;command('publish', Array) 
  6 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/$roadcasting/Broadcasters/RedisBroadcaster.php(99): Illuminate\Redis\Connections\Connection-&gt;__call('publish', Array) 
  7 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastEvent.php(48): Illumin$te\Broadcasting\Broadcasters\RedisBroadcaster-&gt;broadcast(Array, 'order.status', '{"event":"order...') 
  8 [internal function]: Illuminate\Broadcasting\BroadcastEvent-&gt;handle(Object(Illuminate\Broadcasting\Broadcasters\RedisBroadcaster)) 
  $ /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array) 
  10 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Container/BoundMetho$.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() 
  11 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Ob$ect(Illuminate\Foundation\Application), Array, Object(Closure)) 
  12 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundatio$\Application), Array, Array, NULL) 
  13 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container-&gt;call(Array) 
  14 /Users/Shared/dev/php/toters-api/vendor/laravel/frame$ork/src/Illuminate/Pipeline/Pipeline.php(114): Illuminate\Bus\Dispatcher-&gt;Illuminate\Bus\{closure}(Object(Illuminate\Broadcasting\BroadcastEvent)) 
  15 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipe$ine.php(102): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Broadcasting\BroadcastEvent)) 
  16 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pip$line\Pipeline-&gt;then(Object(Closure)) 
  17 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(42): Illuminate\Bus\Dispatcher-&gt;dispatchNow(Object(Illuminate\Broadcasting\BroadcastEvent), fal$e) 
  18 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(69): Illuminate\Queue\CallQueuedHandler-&gt;call(Object(Illuminate\Queue\Jobs\SyncJob), Array) 
  19 /Users/Shared/dev/php/toters-api/vendor/la$avel/framework/src/Illuminate/Queue/SyncQueue.php(42): Illuminate\Queue\Jobs\Job-&gt;fire() 
  20 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Queue/Queue.php(42): Illuminate\Queue\SyncQueue-&gt;push(Object(Illuminate$Broadcasting\BroadcastEvent), '', NULL) 
  21 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastManager.php(128): Illuminate\Queue\Queue-&gt;pushOn(NULL, Object(Illuminate\Broadcasting\BroadcastEve$t)) 
  22 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(270): Illuminate\Broadcasting\BroadcastManager-&gt;queue(Object(App\Events\OrderStatusChanged)) 
  23 /Users/Shared/dev/php/toters-api/vend$r/laravel/framework/src/Illuminate/Events/Dispatcher.php(193): Illuminate\Events\Dispatcher-&gt;broadcastEvent(Object(App\Events\OrderStatusChanged)) 
  24 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/he$pers.php(446): Illuminate\Events\Dispatcher-&gt;dispatch('App\\Events\\Orde...') 
  25 /Users/Shared/dev/php/toters-api/app/Repositories/Orders/AppOrdersRepo.php(107): event(Object(App\Events\OrderStatusChanged)) 
  </code></pre>
  
  <p>How do I fix this?</p>