Pusher Protocol

Socket Conveyor can act as a drop-in WebSocket and REST broadcast server using the Pusher protocol. This lets you use Laravel's built-in reverb or pusher broadcaster, Laravel Echo, and the standard pusher-js client without changing your application code.


When to use Pusher mode

Use Pusher-compatible mode when:

  • You want to keep using Laravel's event broadcasting system (broadcast(), ShouldBroadcast, etc.).
  • Your frontend uses Laravel Echo (window.Echo.channel(), .private(), .join(), etc.).
  • You want to reuse the Pusher wire format so existing pusher-js clients and Laravel's broadcaster just work.
  • You are replacing or augmenting Laravel Reverb with Conveyor for performance, deployment, or scaling reasons.

Native Conveyor mode is simpler for custom WebSocket clients that do not go through Laravel Echo.

Start Conveyor in Pusher mode

1<?php
2
3use Conveyor\Constants;
4use Conveyor\ConveyorServer;
5
6require __DIR__ . '/vendor/autoload.php';
7
8(new ConveyorServer())
9    ->host('127.0.0.1')
10    ->port(8990)
11    ->serverOptions([
12        'worker_num' => 1,
13        'task_worker_num' => 1,
14    ])
15    ->conveyorOptions([
16        Constants::WEBSOCKET_SUBPROTOCOL => Constants::PUSHER,
17        Constants::USE_PRESENCE => true,
18        Constants::APPS => [[
19            'app_id' => 'local-app',
20            'key' => 'local-key',
21            'secret' => 'local-secret',
22            'enable_client_messages' => true,
23            'enabled' => true,
24        ]],
25    ])
26    ->start();

Key points:

  • Constants::PUSHER selects the pusher.com WebSocket subprotocol.
  • APPS defines one or more logical Pusher apps. Each app has an id, key, and secret that must match your Laravel broadcasting config.
  • enable_client_messages allows client events (whispers) when using presence or private channels with client events enabled.
  • USE_PRESENCE enables presence channel support.

The repository includes a runnable example:

1php examples/pusher-real/run-conveyor.php

Connection URL

Clients connect using the standard Pusher connection path:

1ws://127.0.0.1:8990/app/local-key

Conveyor expects the app key in the path. On a successful handshake for a known and enabled app, it responds with a pusher:connection_established event containing a socket_id.

If the app key is unknown or the app is disabled, Conveyor sends a pusher:error with code 4001 and closes the socket.

Apps configuration

The APPS array supports multiple applications:

1Constants::APPS => [
2    [
3        'app_id' => 'app-1',
4        'key' => 'key-1',
5        'secret' => 'secret-1',
6        'enable_client_messages' => true,
7        'enabled' => true,
8    ],
9    [
10        'app_id' => 'app-2',
11        'key' => 'key-2',
12        'secret' => 'secret-2',
13        'enable_client_messages' => false,
14        'enabled' => true,
15    ],
16],

Each app is isolated: connections and channels are scoped per app key.

REST broadcast API

Laravel's reverb and pusher broadcasters publish events by making authenticated HTTP POST requests to:

1POST /apps/{app_id}/events

Conveyor implements the compatible REST endpoint. It validates the Pusher signature using your app secret and then delivers the event payload to all matching WebSocket connections.

This is how broadcast(new MyEvent(...)) and broadcast(...)->toOthers() work when BROADCAST_CONNECTION=reverb (or pusher) points at Conveyor.

Presence and private channels

Presence and private channel authorization is still performed by your Laravel application at the standard /broadcasting/auth endpoint. Conveyor only handles the WebSocket transport and the publish REST API.

For the client-side presence API and examples, see the dedicated Presence page.

Point Echo's WebSocket host at Conveyor, but keep the authEndpoint pointed at your Laravel HTTP application.

Next steps

  • Laravel Echo / Reverb — full guide for configuring Laravel, Echo, environment variables, and authorization.
  • Authorization — details on how Laravel Echo authorization works with Conveyor.
  • Usage — native Conveyor mode for direct WebSocket clients.