php - Laravel real time chat with websockets

Hi I am tring to build a real time chat application with websockets but whenever I try to go visit http://127.0.0.1:8000/laravel-websockets I get error 404 not found. I did all the steps like in the documentation so I don't understand what might be the issue: Followed all the steps here:

https://beyondco.de/docs/laravel-websockets/basic-usage/starting

websockets config

'apps' => [
    [
        'id' => env('PUSHER_APP_ID'),
        'name' => env('APP_NAME'),
        'key' => env('PUSHER_APP_KEY'),
        'secret' => env('PUSHER_APP_SECRET'),
        'path' => env('PUSHER_APP_PATH'),
        'capacity' => null,
        'enable_client_messages' => false,
        'enable_statistics' => true,
    ],
]

.env file

PUSHER_APP_ID=anyID
PUSHER_APP_KEY=anyKey
PUSHER_APP_SECRET=anySecret
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

Answer

Solution:

First of all, as the documentation refers there is no line capacity second thing please make sure that you have followed the steps correctly, and make sure you set your APP_URL in the .env file properly. Try using Homestead or Valet as sometimes setting the URL to localhost or 127.0.0.1:8000 doesn't seem to work properly.

I have just did a quick test to check if something might go wrong but all seems to be working just as expected.

enter image description here

.env file:

APP_URL=http://homestead.laravel_websocket
...
PUSHER_APP_ID=moayadapp
PUSHER_APP_KEY=moayadkey
PUSHER_APP_SECRET=moayadsecret
PUSHER_APP_CLUSTER=mt1

websockets.php

'apps' => [
    [
        'id' => env('PUSHER_APP_ID'),
        'name' => env('APP_NAME'),
        'key' => env('PUSHER_APP_KEY'),
        'secret' => env('PUSHER_APP_SECRET'),
        'path' => env('PUSHER_APP_PATH'),
//        'capacity' => null,
        'enable_client_messages' => false,
        'enable_statistics' => true,
    ],
],

Answer

Solution:

I fixed this problem by running this command

php artisan config:clear

Source