Spectivis Cloud
Reverb and WebSockets
WebSockets work for any app, and Laravel Reverb runs inside your instance when you switch it on.
WebSockets
Section titled “WebSockets”WebSockets work for any app. They pass through Cloudflare to your environment. An open connection counts as activity, so the environment stays awake while someone is connected. Cloudflare can close long connections when it restarts its servers, so make your client reconnect.
Laravel Reverb
Section titled “Laravel Reverb”Laravel Reverb is a switch in your environment’s settings. It is off by default.
Before you turn it on, add the pcntl PHP extension to your composer.json and push:
"require": { "ext-pcntl": "*"}Run composer update --lock so the lock file agrees. Cloud’s build installs the PHP extensions your composer.json asks for, and Reverb will not start without this one. If it is missing, the deploy still goes live, the web process keeps serving and the Logs page shows Undefined constant ... SIGINT from the reverb process.
When it is on:
- Reverb runs inside the same instance, next to the web server, the queue worker and the scheduler. It costs nothing extra and shares the instance’s memory and CPU.
- It is served on your environment’s own address. Cloud sends the paths
/app/*and/apps/*to Reverb and everything else to your app. - Cloud sets
REVERB_APP_ID,REVERB_APP_KEYandREVERB_APP_SECRET. - Your app sends events to Reverb inside its own instance:
REVERB_HOST=127.0.0.1,REVERB_PORT=8081,REVERB_SCHEME=http. Broadcasts stay on the server and do not keep the app awake. - Browsers connect to your environment’s address:
VITE_REVERB_HOSTis the address,VITE_REVERB_PORTis 443 andVITE_REVERB_SCHEMEishttps. Laravel Echo in the starter kits reads these. If you build the client settings in PHP instead, read theVITE_REVERB_*values, notREVERB_HOST.
Things to know
Section titled “Things to know”- Because a connected visitor keeps the environment awake, an app with a busy WebSocket page will rarely sleep. That uses credit.
- Plan for the instance’s memory: every open connection uses some.