php - Why Laravel Pusher is not working in server
问题描述
I am using Pusher in my Web Application. My backend is built with Laravel & Frontend is built with Angular 10. Everything works perfectly in my local machine. But in the server it is not working. The client is failing to connect stating the following error:
Pusher : : [{"type":"WebSocketError","error":{"type":"PusherError","data":{"code":4001,"message":"Could not find app key `4895a6a5e4626a3afdfb`."}}}]
In my local machine, everything is working properly. Both in the angular and the laravel project, I am using the same app key. And the keys are correctly collected from the pusher website.
Here is my Client Connecting Code:
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',
}
};
And in my laravel env:
PUSHER_APP_ID=1069575
PUSHER_APP_KEY=4895a6a5e4626a3afdfb
PUSHER_APP_SECRET=__its_correct_as_well__
PUSHER_APP_CLUSTER=mt1
in 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'
],
],
everything is working properly in the local machine. But in server this fails If you go to the following url, you will see, socket is getting connecting by laravel. http://api.etakweet.com/laravel-websockets
I have also noticed, no logs were found when event is getting broadcasted by laravel project.
解决方案
通过运行以下命令管理连接。
php artisan config:clear
推荐阅读
- python - 根据数据框中的日期时间创建订单列
- javascript - JavaScript Web Worker 消息
- regex - bash grep regex 如何不 grep 时间戳
- reactjs - 在 react redux thunk 执行后,useSelector 值没有立即改变
- javascript - 不和谐机器人如果仅当可验证等于是时声明,机器人发送嵌入
- javascript - 拥有内容时如何创建 PDF 文件的 Blob
- c# - 从远程 IIS 服务器上传时,上传的文件没有内容
- c# - Entity Framework Linq to SQL 创建重复条目
- docker - 使用 docker 内部 IP 地址时没有得到输出
- html - 反应功能
在此不起作用