Echo.socketId() undefined
See original GitHub issueI’m trying to setup a toOthers() broadcast for a Dropzone
I’ve tried to add the X-Socket-ID to Dropzone but when I do Echo.socketId() it is undefined.
My setup of Echo is
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'key',
cluster: 'eu',
encrypted: true
})
console.log(Echo.socketId()) // undefined
Within my package.json I have laravel-echo 1.2.5
Issue Analytics
- State:
- Created 7 years ago
- Comments:7
Top Results From Across the Web
Laravel Echo - Echo.socketId() undefined - Laracasts
I'm trying to setup a toOthers() broadcast for a Dropzone. I've tried to add the X-Socket-ID to Dropzone but when I do Echo.socketId()...
Read more >Laravel Echo callback - Stack Overflow
const socket = io('http://localhost'); console.log(socket.id); // undefined socket.on('connect', () => { console.
Read more >How to use the laravel-echo function in laravel-echo - Snyk
To help you get started, we've selected a few laravel-echo examples, based on popular ... Echo.socketId() return config }, error => Promise.reject(error) ...
Read more >Laravel Websockets with Nuxt - Introduction and demo
hi, I am using laravel echo with nuxt auth 5 to add private channels to my ... echo.socketId() if (socketId) { config.headers.common['X-Socket-ID'] ...
Read more >Pusher Channels Docs | How to exclude event recipients
socketId = pusher.connection.socket_id; });. Once the socket_id has been accessed it can be used when triggering an event on the server by passing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I scanned through Echo source and Pusher docs and here’s a solution:
Though I have to say that I’m not a massive fan.
I had the same problem. What happens is that your console.log fires before the connection has been instantiated (because it happens async) and therefore socketId() will fire undefined. You will see that if you put a timeout on your console.log() you will be able to receive the socketId.
I have been looking for an event that fires when the connection has been made to hook in to it but have not found it. (i am using socket.io, i actually have seen somebody find this hook using pusher but can’t find the post anymore)