Before I posted this question, I checked other SO/articles with the same problem but did not really fixed anything. My freshly installed Laravel 8 application is not registering the events in dashboard though I can see the events if in Laravel.log file. This is the tutorial that I was following. In .env file, if I change the BROADCAST_DRIVER value to log, I can see in the log file the following:
local.INFO: Broadcasting [chatapplication] on channels [public.chatapplication.1] with payload:
{
"test": 123,
"data": "send data",
"socket": null
}
Below is the code that I tried to follow in the tutorial:
.env
BROADCAST_DRIVER=log # or pusher
QUEUE_CONNECTION=sync
# App\Events\ChatApplication
class ChatApplication implements ShouldBroadcast
{
public function broadcastOn()
{
// return new PrivateChannel('channel-name');
$info = new Channel('public.chatapplication.1');
Log::info($info);
return $info;
}
public function broadcastAs()
{
return "chatapplication";
}
.....
}
#config/broadcasting.php
'connections' => [
....
'pusher' => [
....
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => false,
'encrypted' => false,
'host' => '127.0.0.1',
'port' => 6001,
'scheme' => 'http'
],
],
....
];
I am trying to trigger the events in both php artisan tinker and in route and still nothing.
#web.php
Route::get('/chat-application', function () {
event(new \App\Events\ChatApplication("send data"));
});
The same event(new \App\Events\ChatApplication("send data")) in tinker . returned empty array.
The expected output should be events is displayed in dashboard. I read about queues and other things on other post but I dont really now where I should change. I am running in windows with wamp server
Related
Pusher worked, but stopped. The .env settings are 100% correct. Please tell me how to debug this? Also, I tried to make new Puser app
Pusher : State changed : connecting -> connected with new socket ID 126791.4368004
pusher.min.js:8 Pusher : Event sent : {"event":"pusher:subscribe","data":{"auth":":88536630b30af895eb4ac1fcab4af7fcac1fbce3883074b00aa47cfc873c9362","channel":"private-user.1971"}}
pusher.min.js:8 Pusher : Event recd : {"event":"pusher:error","data":{"code":null,"message":"Auth value for subscription to private-user.1971 is invalid: should be of format 'key:signature'"}}
pusher.min.js:8 Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":null,"message":"Auth value for subscription to private-user.1971 is invalid: should be of format 'key:signature'"}}}
PUSHER_APP_ID=902144
PUSHER_APP_KEY=0dd4fc93384fc94b5d6b
PUSHER_APP_SECRET=*****************
var pusher = new Pusher('0dd4fc93384fc94b5d6b', {
cluster: 'eu',
forceTLS: true,
auth: {
headers: {
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
}
}
});
class PusherController extends Controller
{
public $pusher;
public function __construct ()
{
$this->middleware('auth');
$this->pusher = new Pusher(env('PUSHER_APP_KEY'), env('PUSHER_APP_SECRET'), env('PUSHER_APP_ID'));
}
public function auth(Request $request)
{
if (Auth::check()) {
return $this->pusher->socket_auth($request->get('channel_name'), $request->get('socket_id'));
} else {
return Response::make('Forbidden', 403);
}
}
}
Broadcasting.php:
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => 'eu',
'useTLS' => true
],
],
Everything worked, but at some point it stopped. I'm desperate :(
Do not use env(...) outside of config files. Use the config(...) with reference to the file and key you need. Example: config('broadcasting.pusher.key')
If you cache the configuration the .env file does not get loaded which means env(...) returns null for everything.
Sounds like you cached your configuration. You can test this theory by clearing the configuration cache:
php artisan config:clear
If it starts working again that was your issue.
"If you execute the config:cache command during your deployment process, you should be sure that you are only calling the env function from within your configuration files. Once the configuration has been cached, the .env file will not be loaded and all calls to the env function will return null."
Laravel 5.8 Docs - Configuration - Configuration Caching
In laravel 5.6 documentation it says You can use a different driver from the defaults when You create a log
Creating Monolog Handler Channels
So I tried the following in the config/logging.php file
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['masterLog', 'daily'],
],
'email' => [
'driver' => 'monolog',
'handler' => Monolog\Handler\SwiftMailerHandler::class,
'with' => [
'mailer' => Mail::to('test#test.com')->send(new App\Mail\TestMail()),
],
'level' => 'debug',
],
I created my own email channel with the handler Monolog\Handler\SwiftMailerHandler::class and I noticed the class constructor recives a mailer object so I try this
Mail::to('test#test.com')->send(new App\Mail\TestMail())
but I get the following error
RuntimeException
A facade root has not been set.
I'm testing the error by this way
try {
throw new Exception('Test Error');
} catch (\Exception $e) {
Log::stack(['datePayments', 'stack', 'email'])->emergency("user error", ['error' => $e, 'userID'=>Auth::id()]);
}
So how can I configure this to make it works?
Theres a package here https://github.com/designmynight/laravel-log-mailer that adds a mail driver to Laravel's LogManager which should do exactly what you are after.
Using a fresh install of Laravel and dusk, then copying the exact test from the docs for logging in the user, I get an error that the users table doesn't exist.
I don't get any error when using a factory to create a user, but when trying to login as that user, i can see the browser window opening (screenshoots), typing in the creds, then seeing the error that user can't be found.
I see that Dusk tests never ran the migrations.
I change my config/database.php and .env.dusk.local
// config/database.php
'connections' => [
'testing' => [
'driver' => 'sqlite',
'database' => database_path('testing.sqlite'),
'prefix' => '',
],
],
`// .env.dusk.local
APP_URL=http://project.dev
APP_ENV=testing
DB_CONNECTION=testing`
and ran composer update but the error persist :( my test code:
public function setUp() {
parent::SetUp();
factory(Rol::class)->create(['nombre' => 'Administrador']);
$this->usuario = factory(Usuario::class)->create(['email' => 'correo#ejemplo.com', 'password' => bcrypt('123456'), 'rol_id' => Rol::where('nombre', 'Administrador')->first()->id]);
}
/**
* #tests
*/
public function loggeo_usuario() {
$this->browse(function (Browser $browser) {
$browser->visit(route('login'))
->assertSee('Correo')
->type('email', $this->usuario->email)
->type('#password', '123456')
->click('#login-button')
->assertSee('Ayuda');
});
}
I have installed payum for laravel 5 but my providers are not updating correctly.
I added 'Payum\LaravelPackage\PayumServiceProvider' to app/config/app.php file.
'providers' => [
...
//All my providers
'Payum\LaravelPackage\PayumServiceProvider',
],
also tried as
'providers' => [
...
//All my providers
Payum\LaravelPackage\PayumServiceProvider::class,
],
anyway the error message i get whenever i try to use artisan to make a controller or any other thing is:
am i missing any configuration for the service provider? any help will be apreciated.
EDIT: i have created a new provider and stopped using the default provider.
i ran php artisan make:provider PayumServiceProvider
and into its register method pasted:
...
public function register()
{
$this->app->resolving('payum.builder', function(\Payum\Core\PayumBuilder $payumBuilder) {
$payumBuilder
// this method registers filesystem storages, consider to change them to something more
// sophisticated, like eloquent storage
->addDefaultStorages()
->addGateway('paypal_ec', [
'factory' => 'paypal_express_checkout',
'username' => 'EDIT ME',
'password' => 'EDIT ME',
'signature' => 'EDIT ME',
'sandbox' => true
]);
});
}
...
Still not working
Trying to use Laravel 5.3 with pusher, but it seems its not working correct in my code.
My .env is correct
PUSHER_APP_ID= myappid
PUSHER_KEY= mykey
PUSHER_SECRET= mysecret
This is my 'pusher' configurations in broadcasting.php
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_KEY'),
'secret' => env('PUSHER_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => 'eu',
'encrypted' => true,
],
],
I created an event, here it is
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class ProposalEvent implements ShouldBroadcast
{
use InteractsWithSockets, SerializesModels;
public $data;
/**
* Create a new event instance.
*
* #return void
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* Get the channels the event should broadcast on.
*
* #return Channel|array
*/
public function broadcastOn()
{
return ['test-channel'];
// return new PrivateChannel('test-channel');
// return new PresenceChannel('test-channel');
}
}
my javascript
Pusher.logToConsole = true;
var pusher = new Pusher("mykey", {
cluster: 'eu',
encrypted: true
});
var channel = pusher.subscribe('test-channel');
channel.bind('App\\Events\\ProposalEvent', function(data) {
alert(data);
});
and finally in my view
event(new App\Events\ProposalEvent('some data'));
unfortunately this is not working for me, but when i use pusher->trigger like this, without event, it working fine, and i see message in pusher debug console
$options = array(
'cluster' => 'eu',
'encrypted' => true
);
$pusher = new Pusher(
'mykey',
'mysecret',
'myid',
$options
);
$data['message'] = 'some data';
$pusher->trigger('test-channel', 'my-event', $data);
I have searched for solution in Laravel documentation and other resources. There are questions with same problem in stackoverflow, but there are no response.I will be grateful if somebody can help me, because i can't find solution for several days
I was stuck in the same situation and found out that I wasn't using the queue!
In the documentation it says
Before broadcasting events, you will also need to configure and run a queue listener. All event broadcasting is done via queued jobs so that the response time of your application is not seriously affected.
I deleted the config/queue.php file before since I thought I wasn't using it. Maybe you're doing the same thing as me or having some problem with the queue.
Try to pass pusher credentials directly through config/broadcasting.php
It worked for me.
'default' => 'pusher',
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => '***',
'secret' => '**',
'app_id' => '**',
'options' => [
],
],
],
enter code here
triggering event in the views is a mistake when a page is loaded the php is execute first then js is loaded wich mean that you fired event with php before js listner wich will displaye an error this can the first case
the second case is that you didn't downloaded https://curl.haxx.se/docs/caextract.html
if you did go to php.ini and in [curl]you will find somthing like curl-info unecomment it
and right the path to culr file