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.
Managed to connect by running the following command.
php artisan config:clear
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Laravel is a free open source PHP framework that came out in 2011. Since then, it has been able to become the framework of choice for web developers. One of the main reasons for this is that Laravel makes it easier, faster, and safer to develop complex web applications than any other framework.
https://laravel.com/
Angular is one of the most powerful JavaScript frameworks out there. Google uses this platform to develop a Single Page Application (SPA). This development environment is known primarily because it provides developers with a better environment for combining JavaScript with HTML and CSS. More than half a million sites like google.com, youtube.com, etc. use Angular.
https://angular.io/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.