-
Notifications
You must be signed in to change notification settings - Fork 510
Events being duplicated #60
Comments
When you post to your laravel application with the X-Socket-Id, ensure that it matches the socketID that is being broadcasted to Redis. Maybe try a dd in your broadcasting event. Here is the relevant code on laravel-echo-server. |
It is indeed exactly the same. Here's showing the post request that triggers the event, and I've dd'd the event and you can see the socket id is apart of the event object. Then in the tooltip you can see it is the same as the current socket id but I'm still getting the event. I looked at the code you said and it does seem as it would look thru connected sockets for the X-Socket-Id record, and then passes that socket to the |
@tlaverdure any ideas? Just pushed all my latest code to staging env and it is still duplicating events to current user. And I made sure again that the |
Think you may be implementing this wrong on the Laravel side. If both socket ids match on both laravel and laravel echo server then you should be good to go. When the message is broadcasted to redis is should contain the socket id. With that in hand laravel echo server can broadcast a message as that socket: socket.broadcast.to(channel).emit(message.event, channel, message.data); I believe Example from docs: https://laravel.com/docs/5.3/broadcasting#only-to-others broadcast(new ShippingStatusUpdated($update))->toOthers(); Hope that helps. |
Well, I just reread the documentation and I still feel is functioning incorrectly. The point as I can read is that Wouldn't broadcasting a message as "that socket" mean only the current user would get it? |
I do understand I could be understanding how socket.io works. |
|
@jonnywilliamson perhaps you could shine some light on this for me. |
@tlaverdure so looking through the Although I still don't know why events are going to the current user as well. |
@pfeiferchristopher I've exactly the same issue with Laravel 5.5 and Vue / Axios You found a solution ? |
Sorry, haven't worked on this project since a few weeks after my last comment. |
You have to use the trait InteractsWithSockets. Than the call of dontBroadcastToCurrentUser() method makes sense. |
incase someone is having the same issue,
|
Same problem for me. a) Client side welcome.blade.php b) Server side
|
Just solved my problem by attaching X-Socket-Id in API calls. So it can track back who is the sender based on socket perspective. 👍 |
So even though I have
$this->dontBroadcastToCurrentUser();
in the constructor for a public event it is still being sent to the current user. I've checked and my Echo client is sending theX-Socket-Id
header so thatlaravel-echo-server
should be able to filter out events for the current user's socket id but I'm not sure where to start debugging this.The text was updated successfully, but these errors were encountered: