I set up an event and new channel :
class TaskCreated implements shouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $task;
public function __construct(Task $task)
{
$this->task = $task;
}
}
and installed Echo and set it up
import Echo from "laravel-echo"
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'pusher-key',
cluster: 'ap2',
encrypted: true
});
then I call the TaskCreated event when a task is posted
event(new TaskCreated($task));
However, the issue is Echo doesn't listen to pusher logs or ANYTHING. even though in laravel-websockets the event was created as an api-message.
here is vue js Echo implementation :
mounted () {
axios.get('/tasks').then(response => (this.tasks = response.data));
Echo.channel('taskCreated').listen('TaskCreated', (e) => {
console.log(e);
this.tasks.push(task.body)
});
in the dashboard :
api-message Channel: taskCreated, Event: AppEventsTaskCreated 19:01:55
UPDATE
Now when I tried to connect with WS the connection status is pending for 10 seconds then finished with an error WebSocket is closed before the connection is established. AND Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID.
Request URL: wss://127.0.0.1/app/local?protocol=7&client=js&version=6.0.2&flash=false
import Echo from "laravel-echo"
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
wsHost: window.location.hostname,
wssPort: 6001,
disableStats: true,
enabledTransports: ['ws', 'wss']
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…