Using Laravel Events without Pusher nor Redis?

Viewed 4230

I am surprised that I need third-party services such as Pusher or Redis to have a bidirectional communication from my server to my clients through WebSockets.

What are the advantages of Pusher over Redis or simply a socker.io server aside from nginx? I see many disadvantages:

  • Rely on a third-party service
  • Pricy above 200k messages a day
  • Cannot work on LAN without Internet

From my understanding, they are only two possible solutions with Laravel:

  • Laravel Echo + Redis
  • Pusher
    • Laravel Websockets
    • Pusher Php Server

Is there a third alternative?

2 Answers

There is a clone of pusher server available on laravel, have you checked it?

https://beyondco.de/docs/laravel-websockets/getting-started/introduction

  • You can use this on LAN.
  • This runs a php-socket server on some port like 5000
  • Just use Laravel Echo or Pusher SDK for mobile apps and connect it to your server on 5000 port.

You don't have to pay anyone, it runs clone of pusher server on your server.

The benefits of using a third party solution are different per use case and per person. However, broadly speaking there are a couple of benefits that haven't been mentioned here that are worth highlighting:

  • Hosted solutions do not require you to implement your own infrastructure to manage the websocket connections. This means you don't need to worry about the uptime, security, provisioning or maintenance of the infrastructure, this is done for you.
  • Hosted solutions scale seamlessly. As your app user base grows and your connections grow, you no longer need to provision more infrastructure and load balance/route connections.
  • Hosted solutions such as Pusher have dedicated support teams to help during implementation/troubleshooting.
  • Hosted solutions often have round the clock server monitoring, ensuring the platform is available 24/7 without the need for you to respond to server alarms in the early hours.

A lot has been said about build vs buy over the years, and there are many resources that discuss the merits of both (in fact Pusher has a resource for this). Ultimately this is not a decision that can be made for you, you will need to assess your application requirements and then look at what best fits your use case.

Related