Closed michaelnabil230 closed 7 months ago
where does reverb.test
go? I suspect you want to type localhost
or another hostname directing to an IP
When set in hostname localhost on the env, prints in the console error and doesn't connect
If you don't have an SSL certificate for the domain (common for local development), you should set the REVERB_SCHEME=http
rather than https
. This will prevent Echo from connecting via secure WebSockets (wss).
I'm using Herd and the SSL is created by Herd
If you start the server with the --debug
option, do you see the connection attempt?
Is printing after 3 times failed a request from echo
+1 here - Not to sure if this helps, but I have the same error on Safari as well
[Error] WebSocket connection to 'wss://0.0.0.0:8080/app/laravel-herd?protocol=7&client=js&version=8.4.0-rc2&flash=false' failed: bad URL
I'm using Herd Pro to manage the reverb service. My config used for reverb is as show in the Herd Pro screenshot, and the error occurs regardless if REVERB_SCHEME
is set to http
or https
. I logged the output of window.Echo.options
to my console and this it is as follows:
{
"broadcaster": "reverb",
"enabledTransports": ["ws", "wss"],
"forceTLS": true,
"key": "laravel-herd",
"wsHost": "0.0.0.0",
"wsPort": "8080",
"wssPort": "8080,",
}
My steps to reproduce
artisan broadcasting:install
, install deps and use Reverb@vite
directive into welcome.blade.php
+1 here as well. Same issue - Herd Pro, using reverb service, with SSL (via Herd)...
REVERB_APP_ID=1001
REVERB_APP_KEY=laravel-herd
REVERB_APP_SECRET=secret
REVERB_HOST="demoapp.test" // Using the name of the project as it says in the Herd instructions
REVERB_PORT=8080
// REVERB_SCHEME defaults to https so leaving that unset
Turning off SSL in Herd, changing the APP_URL to http..., and updating the .env settings for Reverb:
REVERB_APP_ID=1001
REVERB_APP_KEY=laravel-herd
REVERB_APP_SECRET=secret
REVERB_HOST="0.0.0.0"
# REVERB_HOST="deskninja.test"
REVERB_PORT=8080
REVERB_SCHEME=http
Got this working locally. Likely an issue with the SSL. I saw in the docs you could target the SSL cert by entering it in the settings, going to mess around and see if that fixes it.
I can confirm @fylzero findings - Removing SSL on Herd and setting REVERB_SCHEME
to http
does seem to fix the issue and allows a Reverb connection.
Using SSL is a different story. I can get a connection with the following below with SSL switched on in Herd, however it seems to disconnect after 30ish seconds with the same WebSocket connection to 'wss://0.0.0.0:8080...' failed: bad URL
APP_URL=https://reverb-test.test
REVERB_APP_ID=1001
REVERB_APP_KEY=laravel-herd
REVERB_APP_SECRET=secret
REVERB_HOST="reverb-test.test"
REVERB_PORT=8080
REVERB_SCHEME=https # Force TLS
I just ran through the SSL setup with the following steps and am able to connect (FF, Safari and Chrome) with no issues over wss using the following steps:
reverb-ssl.test
)php artisan install:broadcasting
REVERB_HOST=reverb-ssl.test
in my environmentReverb lets me know I'm starting a secure server:
And I'm able to connect:
@aj-norman, if you're seeing Echo trying to connect to 0.0.0.0, it's likely you either haven't rebuilt your frontend since updating REVERB_HOST
or your VITE_REVERB_HOST
variable hasn't been updated.
@fylzero The built-in Reverb service doesn't have SSL support (yet).
I believe it must be something in the migration from Laravel 10 to 11, I had 10 with laravel websockets running fine, but after the update I'm no longer able to do so.
I just ran through the SSL setup with the following steps and am able to connect (FF, Safari and Chrome) with no issues over wss using the following steps:
- Install Laravel 11 app (reverb-ssl available at
reverb-ssl.test
)- Secure with Herd
- Install broadcasting
php artisan install:broadcasting
- Update
REVERB_HOST=reverb-ssl.test
in my environment- Rebuild assets
Reverb lets me know I'm starting a secure server:
And I'm able to connect:
@aj-norman, if you're seeing Echo trying to connect to 0.0.0.0, it's likely you either haven't rebuilt your frontend since updating
REVERB_HOST
or yourVITE_REVERB_HOST
variable hasn't been updated.@fylzero The built-in Reverb service doesn't have SSL support (yet).
in my tests, run npm run dev "vite dev" the connection of websockets return success but in vite port after build assets, not return error and connection more.
@joedixon - Apologies, I should have made it clearer above - I changed the 0.0.0.0
to my reverb-test.test
domain and that worked on a http
connection, but SSL still has issues when trying https
. However I think you've cleared it up with the following statement above
The built-in Reverb service doesn't have SSL support (yet).
in my tests, run npm run dev "vite dev" the connection of websockets return success but in vite port
@lsdevelop that's not the Reverb socket server, that's part of the Vite dev server which is why you don't see it after building your assets for production.
in my tests, run npm run dev "vite dev" the connection of websockets return success but in vite port
@lsdevelop that's not the Reverb socket server, that's part of the Vite dev server which is why you don't see it after building your assets for production.
Yeah, my f** stupidity
So is your issue resolved now @lsdevelop?
So is your issue resolved now @lsdevelop?
Nope, I'm start trying create new laravel project with broadcasting to validate my migrated files (10 with laravel websockets to 11 with reverb)
It sounds to me like this is an issue with Herd not supporting SSL for their Reverb service. Maybe this is also the cause of the Safari issue? Going to experiment more today.
@lsdevelop I can say that I do not believe this is related to the upgrade. I did a diff check on a fresh project and made sure everything was setup the same as a new project. That said, when I upgraded, it did not add the broadcast config for Reverb....but this did not resolve my issue.
Note: The upgrade/broadcast config issue was just resolved here - https://github.com/laravel/reverb/pull/84
@joedixon Can you share the Reverb start command you used for SSL? Did you just run php artisan reverb:start
or was it more than that?
@fylzero just php artisan reverb:start
, but you need to ensure REVERB_HOSTNAME
is set to a domain served by Herd and that domain must be secured by Herd. Reverb will detect the rest.
@joedixon I just tried this and Reverb does not work this way. I'm a bit confused, in Herd when using the Reverb service, it provides the REVERB_APP_ID, REVERB_APP_KEY, and REVERB_APP_SECRET. When removing the Herd Reverb service and using php artisan reverb:start
how do we/does it know what these values should be?
Currently:
REVERB_APP_ID=1001
REVERB_APP_KEY=laravel-herd
REVERB_APP_SECRET=secret
REVERB_HOST="myapp.test"
REVERB_PORT=8080
REVERB_SCHEME=https
Also, I think about you meant REVERB_HOST
as REVERB_HOSTNAME
is not referenced in any configs - though the config key is hostname.
I've opened a bug with Herd: https://github.com/beyondcode/herd-community/issues/467
@lsdevelop I can say that I do not believe this is related to the upgrade. I did a diff check on a fresh project and made sure everything was setup the same as a new project. That said, when I upgraded, it did not add the broadcast config for Reverb....but this did not resolve my issue.
Note: The upgrade/broadcast config issue was just resolved here - #84
@joedixon Can you share the Reverb start command you used for SSL? Did you just run
php artisan reverb:start
or was it more than that?
After update broadcast.php, the connection has return this, i`m continue trying.
@joedixon I just tried this and Reverb does not work this way. I'm a bit confused, in Herd when using the Reverb service, it provides the REVERB_APP_ID, REVERB_APP_KEY, and REVERB_APP_SECRET. When removing the Herd Reverb service and using
php artisan reverb:start
how do we/does it know what these values should be?Currently:
REVERB_APP_ID=1001 REVERB_APP_KEY=laravel-herd REVERB_APP_SECRET=secret REVERB_HOST="myapp.test" REVERB_PORT=8080 REVERB_SCHEME=https
Also, I think about you meant
REVERB_HOST
asREVERB_HOSTNAME
is not referenced in any configs - though the config key is hostname.I've opened a bug with Herd: beyondcode/herd-community#467
I'm not sure it's a bug with Herd, it's just not supported on the built-in service yet.
The app key, id and secret can be anything, but if you remove them all from your .env and run reverb:install
, they will be populated for you.
@joedixon Apologies. I'm not sure I understand the difference between Herd's Reverb service and the built-in service. Can you clarify that?
Also, that's great those can be anything. Then do you have any thoughts as to why this isn't working for me with the reverb:start command?
Thanks!
Herd's service is completely separate from your application. It's essentially a standalone Laravel application running Reverb which any of your own applications can connect to. It's really for use in scenarios where you want to use Reverb, but not have it running alongside your application.
What's the error you're seeing when trying to start the server with reverb:start
?
@joedixon Ok, so - using the Herd Reverb service without SSL, everything with Reverb works.
If I...
php artisan reverb:start
I get the error: WebSocket connection to 'wss://myapp.test:8080/app/laravel-herd?protocol=7&client=js&version=8.4.0-rc2&flash=false' failed:
...and the websocket event does nothing. No other errors.
What is displayed in the console after running the reverb:start command?
@joedixon
INFO Starting secure server on 0.0.0.0:8080 (myapp.test).
Can you use the --debug option when starting the command to see if any connection events are being sent to the server?
@joedixon Did --debug, tried executing a Reverb event again. Nothing more is outputting there - and as I mentioned, the browser console shows connection failed.
I do see (after a second or two): Pruning Stale Connections ........................................................................................................................ Pinging Inactive Connections .....................................................................................................................
Ok, if you hit https://myapp.test:8080/app/laravel-herd in the browser, do you get an SSL error or a server error?
@joedixon Says "Internal server error"
Can you share all of your REVERB_
and VITE_REVERB_
prefixed environment variables and your echo configuration?
@joedixon
REVERB_APP_ID=1001
REVERB_APP_KEY=laravel-herd
REVERB_APP_SECRET=secret
REVERB_HOST="myapp.test"
REVERB_PORT=8080
REVERB_SCHEME=https
VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"
Just tested with the exact same configuration and can't replicate it!
Is this a brand new app or existing? If existing, can you send over how Echo is being instantiated?
Can you also let me know the browser and send a screenshot of the error and anything relevant in the console?
@joedixon Existing/upgraded app. Testing in Brave (shields off - basically Chrome). I'm not seeing any errors that haven't been shared already.
I put the Echo code directly in my app.js:
// Echo
import Echo from 'laravel-echo'
import Pusher from 'pusher-js'
window.Pusher = Pusher
window.Echo = new Echo({
broadcaster: 'reverb',
key: import.meta.env.VITE_REVERB_APP_KEY,
wsHost: import.meta.env.VITE_REVERB_HOST,
wsPort: import.meta.env.VITE_REVERB_PORT ?? 80,
wssPort: import.meta.env.VITE_REVERB_PORT ?? 443,
forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
enabledTransports: ['ws', 'wss'],
})
My vue code:
onMounted(() => {
Echo.private(`branch.${page.props.authUser.branch_id}`).listen('IssueCreatedEvent', (event) => {
router.reload({ only: ['issues'] })
})
})
onUnmounted(() => {
Echo.leave(`branch.${page.props.authUser.branch_id}`)
})
I mean this all works without SSL - so I don't think anything is misconfigured. If youre open to it, we can jump on a Google Meet or something to walk through this. My email is just my github username at gmail dot com. I just had ankle surgery so I'm laid up with a laptop and nothing to do. Really appreciate your help here!
Really, non secure working fine, tomorrow i deploy to my staging environment with reverb and ssl to starting tests in similarly production environment
@fylzero can you try a brand new project just so we can rule out anything specific to the project / host?
@joedixon Will do. ...but I've already diff checked to make sure nothing was missing compared to a fresh project. Also, the fact that it works sans-SSL should I think rule that out as an issue.
Update, in production, works fine with SSL, the problem is local and specify from herd/valet.
Hi @joedixon!
I have a similar problem. At first I tried to connect Reverb on the current project, but I got the error WebSocket connection to...
in the browser console.
Then I did a clean install of Laravel using docker in a WSL environment. And I still get the same error: WebSocket connection to 'ws://localhost:8080/app/vorzsu5irbdva48qipku?protocol=7&client=js&version=8.4.0-rc2&flash=false' failed:
sail artisan reverb:start --debug:
INFO Starting server on 0.0.0.0:8080 (localhost).
Pruning Stale Connections ...................................................................
Pinging Inactive Connections ................................................................
Pruning Stale Connections ...................................................................
Pinging Inactive Connections ................................................................
.env:
APP_URL=http://localhost
BROADCAST_CONNECTION=reverb
REVERB_APP_ID=222435
REVERB_APP_KEY=vorzsu5irbdva48qipku
REVERB_APP_SECRET=uig8whxhdpkafmocbn4u
REVERB_HOST="localhost"
REVERB_PORT=8080
REVERB_SCHEME=http
VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"
echo.js:
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
window.Pusher = Pusher;
window.Echo = new Echo({
broadcaster: 'reverb',
key: import.meta.env.VITE_REVERB_APP_KEY,
wsHost: import.meta.env.VITE_REVERB_HOST,
wsPort: import.meta.env.VITE_REVERB_PORT ?? 80,
wssPort: import.meta.env.VITE_REVERB_PORT ?? 443,
forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
enabledTransports: ['ws', 'wss'],
});
I use WSL and Laravel Sail. The server is started using the command sail artisan serve
I have exactly the same problem
Web server: Lightspeed Laravel: version 11
error :
app-CamLVODr.js:13 WebSocket connection to 'wss://mydomain.com/app/cmjnsrygmqfjkdrsmxib?protocol=7&client=js&version=8.4.0-rc2&flash=false' failed:
Hi @joedixon! I have a similar problem. At first I tried to connect Reverb on the current project, but I got the error
WebSocket connection to...
in the browser console. Then I did a clean install of Laravel using docker in a WSL environment. And I still get the same error:WebSocket connection to 'ws://localhost:8080/app/vorzsu5irbdva48qipku?protocol=7&client=js&version=8.4.0-rc2&flash=false' failed:
sail artisan reverb:start --debug:
INFO Starting server on 0.0.0.0:8080 (localhost). Pruning Stale Connections ................................................................... Pinging Inactive Connections ................................................................ Pruning Stale Connections ................................................................... Pinging Inactive Connections ................................................................
.env:
APP_URL=http://localhost BROADCAST_CONNECTION=reverb REVERB_APP_ID=222435 REVERB_APP_KEY=vorzsu5irbdva48qipku REVERB_APP_SECRET=uig8whxhdpkafmocbn4u REVERB_HOST="localhost" REVERB_PORT=8080 REVERB_SCHEME=http VITE_REVERB_APP_KEY="${REVERB_APP_KEY}" VITE_REVERB_HOST="${REVERB_HOST}" VITE_REVERB_PORT="${REVERB_PORT}" VITE_REVERB_SCHEME="${REVERB_SCHEME}"
echo.js:
import Echo from 'laravel-echo'; import Pusher from 'pusher-js'; window.Pusher = Pusher; window.Echo = new Echo({ broadcaster: 'reverb', key: import.meta.env.VITE_REVERB_APP_KEY, wsHost: import.meta.env.VITE_REVERB_HOST, wsPort: import.meta.env.VITE_REVERB_PORT ?? 80, wssPort: import.meta.env.VITE_REVERB_PORT ?? 443, forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https', enabledTransports: ['ws', 'wss'], });
I use WSL and Laravel Sail. The server is started using the command
sail artisan serve
I also encountered this using Laravel Sail (Windows, WSL, Laravel 10 upgraded to 11).
By adding port 8080 (used by Reverb) to docker-compose.yml solved the problem.
@pilutiful That's great! It really works now. Thank you very much!
Closing this now as we have a few different problems merged into the same issue. If you are still running into a problem, please open a new issue.
cluster: 'Redis',
Add this line in your Echo options
Also ran into this one today 😅
Basically, the pusher-js
library (internally used by Echo) will force-enable the useTLS option regardless of your preferences whenever it detects the browser is on a https
(secure) connection.
Or, in other words, regardless of what you're instructing Reverb/Pusher to do, it's going to demand a "secure" websocket connection, as visible in your browser by the fact that it'll try to connect to wss://
instead of ws://
.
To fix this, there's two things you can do:
(If you're running Reverb inside Herd, and as long as those flags are missing, don't forget to turn off that service first, or you'll run into errors regarding the port already being in use!)
hola, lo resolví de la siguiente forma:
agregué la IP en la variable:
REVERB_HOST="192.168.1.88"
y reconstruí con npm un build para que tome los cambios.
Funcionó perfecto!!! incluso lo probé de otros equipos conectados a la misma red de manera exitosa.
Saludos desde Viña del Mar, Chile
Reverb Version
1.0@beta
Laravel Version
v11.0.5
PHP Version
8.3
Description
I tried with the Postman and is connected well and returns the data and socket ID but javascript does not work I don't know where the issue
env file
echo.js
Steps To Reproduce
...