Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Receive Messages on Frontend with (Echo) after Setting Up Laravel Reverb #271

Open
srtamarques opened this issue Nov 8, 2024 · 1 comment

Comments

@srtamarques
Copy link

Laravel Version

11

PHP Version

8.2

Database Driver & Version

No response

Description

Hello, I am facing an issue where my frontend is successfully connecting to the WebSocket server, but it does not receive any messages from the backend. Below are the details of my setup:

Environment:
Laravel Version: 11
WebSocket Server: Laravel WebSockets using the Reverb package
Frontend: Echo (connected to WebSocket)

Steps Taken:
Backend Setup: I have set up the Laravel WebSockets server using the Reverb package, running on localhost:5000.

1- I use the following command to start the server:

image

2- Queue Worker: I am running the queue worker in the background with the following command to process the event:

image

3- Frontend Setup: On the frontend, I use Echo to connect to the WebSocket:

image

4- Event Dispatch: I am dispatching the event on the backend like this:

image

Event:
image
image

5- Frontend Listening: On the frontend, I am subscribing to the channel and listening for the event:

image

Issue:
The connection to the WebSocket server is established successfully (ws://localhost:5000/).
The event is being dispatched and processed by the queue worker successfully.
However, the frontend does not receive any messages when the event is triggered.

Steps To Reproduce

Steps To Reproduce:

Create a new Laravel project and install beyondcode/laravel-websockets or Reverb WebSockets.
Configure the WebSocket server by publishing the necessary configurations and running migrations.
Set up WebSocket broadcasting in .env with the correct Pusher settings.
Start the WebSocket server locally with php artisan websockets:serve.
Create a custom event (e.g., MessageSentTrackingEvent) and configure it to broadcast on a channel.
Set up the frontend (e.g., Vue.js) to connect to the WebSocket server using Echo.
Dispatch the event from the backend using MessageSentTrackingEvent::dispatch().
Listen for the event in the frontend.
Run the queue worker with php artisan queue:work.
After triggering the event, no message is received on the frontend, even though the WebSocket connection is established.

@crynobone crynobone transferred this issue from laravel/framework Nov 11, 2024
@crynobone
Copy link
Member

Hey there, thanks for reporting this issue.

We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here?

Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.

laravel new bug-report --github="--public"

Do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants