nginx laravel-pusher推送器错误:404 Not Found(Ubuntu)404 Not Found

wnavrhmk  于 2023-06-05  发布在  Nginx
关注(0)|答案(1)|浏览(271)

当发生火灾事件时,我收到以下错误

**推送器错误:404 Not Found404 Not Found404 Not Found
web.php

Route::get('test', function () {
event(new App\\Events\\SendMessage('hello world'));
return 'Event has been sent successfully';
});

.env

BROADCAST_DRIVER=pusher

LARAVEL_ECHO_PORT=6001

PUSHER_APP_ID=XXXX
PUSHER_APP_KEY=XXXX
PUSHER_APP_SECRET=XXXX
PUSHER_HOST=127.0.0.1
PUSHER_PORT=80
PUSHER_SCHEME=http
PUSHER_APP_CLUSTER=ap2

app.php

从app.php中的App\Providers\BroadcastServiceProvider::class删除注解

/*
    * Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,

resources/js/bootstrap.js

import Echo from 'laravel-echo';

import Pusher from 'pusher-js';
window.Pusher = Pusher;

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: import.meta.env.VITE_PUSHER_APP_KEY,
    cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'ap2',
    wsHost: import.meta.env.VITE_PUSHER_HOST ??   `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`,
    wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
    wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
    forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
    enabledTransports: ['ws', 'wss'],
});

test.blade.php

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    @vite(['resources/js/app.js'])

</head>
<body>
    <div id="app"></div>
</body>
<script>
      window.laravel_echo_port='{{ env('LARAVEL_ECHO_PORT') }}';
</script>
<script src="//{{ Request::getHost() }}:{{ env('LARAVEL_ECHO_PORT') }}/socket.io/socket.io.js"></script> 
<script type="module">
    window.Echo.channel('send-message-channel')
     .listen('.send-message', (data) => {
         console.log(data);
    });
</script>
</html>
z3yyvxxp

z3yyvxxp1#

这也许能帮到某人
对于那些使用laravel-websockets的用户,请确保在broadcasting.php配置文件中添加了'host' => '127.0.0.1', 'port' => '6001',

相关问题