Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么Laravel Pusher不能在服务器中工作_Php_Angular_Laravel_Pusher_Laravel Websockets - Fatal编程技术网

Php 为什么Laravel Pusher不能在服务器中工作

Php 为什么Laravel Pusher不能在服务器中工作,php,angular,laravel,pusher,laravel-websockets,Php,Angular,Laravel,Pusher,Laravel Websockets,我在我的Web应用程序中使用Pusher。我的后端是用Laravel构建的,前端是用Angular 10构建的。在我的本地机器上,一切都很好。但是在服务器上它不工作。客户端连接失败,出现以下错误: Pusher : : [{"type":"WebSocketError","error":{"type":"PusherError","data":{"code"

我在我的Web应用程序中使用Pusher。我的后端是用Laravel构建的,前端是用Angular 10构建的。在我的本地机器上,一切都很好。但是在服务器上它不工作。客户端连接失败,出现以下错误:

Pusher :  : [{"type":"WebSocketError","error":{"type":"PusherError","data":{"code":4001,"message":"Could not find app key `4895a6a5e4626a3afdfb`."}}}]
在我的本地机器中,一切都正常工作。在angular和laravel项目中,我使用相同的应用程序键。而且钥匙是从pusher网站上正确收集的

以下是我的客户端连接代码:

constructor() {
    console.log(window.location.hostname);
    this.pusher = new Pusher(environment.pusher.key, {
      cluster: environment.pusher.cluster,
      wsHost: '162.214.125.121',
      // wsHost: '127.0.0.1',
      wsPort: 6001,
      encrypted: false,
      forceTLS: false,
    });
    this.channel = this.pusher.subscribe('draw_options');
    Pusher.log = (msg) => {
      console.log(msg);
    };
  }
export const environment = {
  production: false,
  pusher: {
    key: '4895a6a5e4626a3afdfb',
    cluster: 'mt1',
  }
};
在我的生活中:

PUSHER_APP_ID=1069575
PUSHER_APP_KEY=4895a6a5e4626a3afdfb
PUSHER_APP_SECRET=__its_correct_as_well__
PUSHER_APP_CLUSTER=mt1
在my broadcasting.php中

'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => env('PUSHER_APP_CLUSTER'),
                'useTLS' => false,
                'encrypted' => false,
//                'host' => '162.214.125.121',
                'host' => '127.0.0.1',
                'port' => 6001,
                'scheme' => 'http'
            ],
        ],
本地机器中的一切都正常工作。但在服务器中,这会失败 如果您转到以下url,您将看到,socket正在通过laravel进行连接。


我还注意到,当laravel项目广播事件时,没有找到任何日志。

通过运行以下命令进行连接

php artisan config:clear