Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

oncebar's avatar

I can't listen to my events - Inertiajs

how i can listen to my event ? my app developped with laravel + inertia + vue, this is my listen script.

Echo.private('myEventsFile')
    .listen('myEventName', (e) => {
        console.log('niiiiiiiiiice')
    })

i see this error. POST http://127.0.0.1:8000/broadcasting/auth 403 (Forbidden)

0 likes
6 replies
Sinnbeck's avatar

When using broadcastAs you need to prefix it in the listener with a dot

Echo.private('myEventsFile')
    .listen('.myEventName', (e) => {
        console.log('niiiiiiiiiice')
    })

https://laravel.com/docs/9.x/broadcasting#broadcast-name

If you customize the broadcast name using the broadcastAs method, you should make sure to register your listener with a leading . character

1 like
oncebar's avatar

@Sinnbeck This is my channel

class NewVdata implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $VisitorData;

    public function __construct($VisitorData)
    {
        $this->VisitorData = $VisitorData;
    }

    public function broadcastOn()
    {
        return new PrivateChannel('newVdata');
    }
}
oncebar's avatar

and this is my vue script

<script>
import "./styles/Visitorsdata.css"
import Layout from "../../Layout/Dashboard.vue"


    Echo.private('NewVdata')
        .listen('.newVdata', (e) => {
            console.log('niiiiiiiiiice')
        })


export default {
    layout: Layout,
    props: {
        vdata: Array,
    },
}
</script>
oncebar's avatar

i see this errors. POST http://127.0.0.1:8000/broadcasting/auth 403 (Forbidden) Visitorsdata:1 Unchecked runtime.lastError: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received

Sinnbeck's avatar

Well its a private channel. Check your channels.php and make sure that it returns true if the user is allowed

Please or to participate in this conversation.