Skip to content

adityaa-codes/echo-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Echo Server Demo (Laravel + Reverb + DDEV)

This project is a demo websocket backend for mobile SDK integration.

It continuously emits fake events to:

  • public channel
  • private channel (auth required)
  • presence channel (auth + room membership)

1) Prerequisites

1.1 Check Docker

docker --version
docker compose version

If these fail, install Docker Desktop (or Docker Engine + Compose plugin) and start Docker.

1.2 Check DDEV

ddev version

If this fails, install DDEV:

Required for this project:

  • DDEV >= 1.25.1

Upgrade command (script-based installs):

curl -fsSL https://ddev.com/install.sh | bash

If prompted for /usr/local/bin permissions, run it in your local terminal with sudo access.

1.3 Check Cloudflared (for internet sharing)

cloudflared --version

If this fails, install cloudflared:

Common install commands:

  • macOS (Homebrew): brew install cloudflared
  • Windows (winget): winget install --id Cloudflare.cloudflared
  • Ubuntu/Debian: use Cloudflare's official APT steps in the docs above

1.4 Optional checks

git --version

2) Clone Project

git clone https://github.com/adityaa-codes/echo-server echo-server
cd echo-server

3) Bootstrap (one command)

Run:

ddev setup

What ddev setup does:

  1. ddev start
  2. ddev composer install
  3. ddev npm ci
  4. php artisan key:generate
  5. php artisan migrate --seed
  6. php artisan optimize:clear
  7. ddev restart
  8. prints integration values via ddev demo-info

4) Start Demo Runtime (day-to-day)

ddev demo-up

This ensures daemons are running and prints mobile integration details.

5) Verify Everything Is Healthy

5.1 Service status

ddev describe

5.2 Daemon status

ddev exec supervisorctl status reverb scheduler queue cloudflared

Expected: all required services show running.

5.3 End-to-end broadcast smoke test

ddev doctor-demo

This checks daemon state, broadcast auth route, and emits a demo event tick.

6) Data Seeded for Private/Presence Auth

These users are auto-seeded:

  • demo1@example.com / password (userId 1)
  • demo2@example.com / password (userId 2)
  • demo3@example.com / password (userId 3)

7) Mobile Integration Values (single command)

Run:

ddev demo-info

It prints:

  • Main URL
  • Auth URL
  • Reverb app ID and app key
  • public websocket URL(s)
  • channel names
  • event names
  • demo user credentials

8) Current Broadcast Contract

8.1 Channels

  • Public raw channel: demo.public
  • Private raw channel: private-demo.private.{userId}
  • Presence raw channel: presence-demo.presence.{room}

Laravel Echo subscription forms:

  • channel('demo.public')
  • private('demo.private.{userId}')
  • join('demo.presence.{room}')

8.2 Event names

  • demo.public.tick
  • demo.private.tick
  • demo.presence.tick

8.3 Auth endpoint

  • Relative: /broadcasting/auth
  • Default full URL: https://echo-server.ddev.site/broadcasting/auth

9) Runtime Processes

DDEV runs these as background daemons:

  • php artisan reverb:start --host=0.0.0.0 --port=9080
  • php artisan schedule:work
  • php artisan queue:work redis --sleep=1 --tries=1

Scheduled emitter:

  • demo:broadcast-events --user-id=1 --room=main
  • interval: every second

10) Network / Device Notes

  • DDEV has bind_all_interfaces: true enabled.
  • For simulator/emulator, use values from ddev demo-info.
  • For physical device:
    • if *.ddev.site resolves, use that directly.
    • if not, use host machine LAN IP with exposed Reverb port.

11) Troubleshooting

11.1 Docker permission issue

If DDEV commands fail with Docker socket errors, make sure Docker is running and your user can access Docker.

11.2 Daemon not running

ddev restart
ddev exec supervisorctl status reverb scheduler queue cloudflared

11.3 Auth fails for private/presence

  • confirm you are logged in with one of seeded users
  • verify auth URL from ddev demo-info
  • verify channel name includes correct userId / room

11.4 No events arriving

  • run ddev doctor-demo
  • manually emit one tick:
ddev exec php artisan demo:broadcast-events --user-id=1 --room=main

12) Useful Commands Reference

# full bootstrap
ddev setup

# start and print integration info
ddev demo-up

# diagnostics
ddev doctor-demo

# print all mobile integration values
ddev demo-info

# start a public cloudflared share URL
ddev share-cloudflared

# show URLs + ports
ddev describe

13) Share Server Over Internet (Cloudflared Tunnel)

13.1 Quick share (recommended)

ddev share-cloudflared

This generates a random public *.trycloudflare.com subdomain for sharing the server.

13.2 Stable share (same URL every restart)

  1. Configure named tunnel token:
cp .ddev/.env.cloudflared.example .ddev/.env.cloudflared
  1. Set CLOUDFLARED_TUNNEL_TOKEN and CLOUDFLARED_PUBLIC_URL.
  2. Run:
ddev restart
ddev exec supervisorctl status cloudflared

13.3 What to send mobile developers

  1. public share URL
  2. auth path /broadcasting/auth
  3. ddev demo-info output (app key, channels, events, demo users)

13.4 Stop tunnel

  • Quick share: stop ddev share-cloudflared process (Ctrl+C).
  • Stable daemon tunnel: remove token from .ddev/.env.cloudflared and run ddev restart.

About

this repo is a demo server for the echo-android websocket client sdk: https://github.com/adityaa-codes/echo-android. it broadcasts scheduled fake events over public, private, and presence channels so mobile clients can test auth, subscriptions, and realtime event handling end to end.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors