tlaverdure/laravel-echo-server

Cannot recieve broadcasted events in the browser

Ulsah opened this issue · 1 comments

Ulsah commented

Hello there,
I have a real time auctioning platform. I recently decided to switch from Pusher to socket.io. I configured everything and ran the laravel-echo-server command. Everything seems to be fine, except I cannot receive events in the browser. Everything is broadcasted perfectly from the backend. Can someone please help me out?

Versions of packages that are in use:
Laravel: 8
socket.io-client: 4.0.1
laravel-echo-server: 1.6.2
redis-server: 5.0.3
redis-server(package.json): 1.2.2

Here is a screenshot of my laravel-echo-server output(as you can see the event are being received here):
echoserver

Code for broadcasting in my event:
public function broadcastOn() { return new PrivateChannel('auction.fives'); }

My bootstrap.js:

import Echo from 'laravel-echo';
 
 window.io = require('socket.io-client');
 
 window.Echo = new Echo({
    broadcaster: 'socket.io',
    host: '127.0.0.1:6001'
}); 

Listener in my vue file(I tried the event name with and without dot as a prefix. Nothing works):

window.Echo.channel('private-auction.fives')
        		.listen('Fives', (e) => {
        			console.log("sdf");
        			if(e.id == this.$route.params.id){
        				document.getElementById('hdenH').hidden = false;
        				document.getElementById('cdown').hidden = false;
        				this.startTicking();
        			}
        		});

Channels.php:

Broadcast::channel('auction.newbid', function ($bid) {
    return true;
});

I would like to add that pings to localhost:6001 from the browser are returned with a status code 200. As far as I know successful subscription mean a 101 status code. So I'm not sure if something is wrong there.

Any help would be much appreciated.

Thank you

Ulsah commented

I reverted the laravel-echo-server version to 2.3.1 and it worked