Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Can I use API Gateway WebSockets with Laravel Reverb


Can I use API Gateway WebSockets with Laravel Reverb


it seems that using API Gateway WebSockets with Laravel Reverb is not a straightforward solution, as Reverb is designed to be a self-hosted WebSocket server for Laravel applications.

The key points are:

1. Reverb is not really Vapor (AWS Lambda) compatible out of the box: Vapor is designed around a serverless mentality, where you don't have to manage servers yourself. Reverb, on the other hand, requires you to run a dedicated server for the WebSocket functionality.

2. Recommended approach for Vapor applications: For Vapor applications, it's suggested to use a fully serverless WebSocket solution like Pusher or Ably, rather than running your own Reverb server.

3. Potential workaround: If you still want to use Reverb with a Vapor application, the recommended approach is to run the Reverb server on a traditional server, separate from your Vapor application. Then, you can have your Vapor application connect to the remote Reverb server.

4. API Gateway WebSockets: The search results mention that you could potentially use API Gateway WebSockets as a serverless WebSocket solution, which could be integrated with a Reverb server running on a separate traditional server. However, this approach goes against the serverless philosophy of Vapor.

In summary, while it's possible to use API Gateway WebSockets in conjunction with a separately hosted Reverb server, this would not be the recommended approach for Vapor applications. The more "Vapor-friendly" solution would be to use a fully serverless WebSocket offering like Pusher or Ably, which doesn't require managing any servers yourself.

The Laravel team seems to suggest that Reverb is not really designed for Vapor-style serverless environments, and that a dedicated serverless WebSocket solution would be a better fit for Vapor applications.

Citations:
[1] https://www.reddit.com/r/laravel/comments/1ajmd0m/laravel_reverb_firstparty_websocket_server/
[2] https://github.com/brefphp/bref/discussions/1774
[3] https://laravel.com/docs/11.x/reverb
[4] https://stackoverflow.com/questions/78218221/how-to-use-laravel-reverb-as-a-standalone-websocket-server
[5] https://www.youtube.com/watch?v=gv9z1yv0_7k