bcs02123052's avatar

how to keep running Laravel websockets using Laravel cron jobs ?

I want to deploy websocket on shared hosting so i cannot install the supervisor ,

can i check is websocket running by using artisan class of Laravel ?

0 likes
1 reply
bobbybouwmann's avatar

In short: You can't.

You need to have a background process that keeps running the WebSocket for you. Also, you need a different port for your WebSocket server. Because you're on shared hosting an extra port is probably blocked. This is how PHP is designed and shared hosting is simply not set up for this. You need your own server where you have more flexibility. You can read a more detailed answer here: https://stackoverflow.com/a/55987092

However, there is a solution to make this work. Simply replace the WebSocket on your own server with a WebSocket as a service like Pusher. Pusher is supported out of the box by Laravel and offers almost the same functionality. You can use the broadcast system from Laravel to send out a message to Pusher, where Pusher will broadcast it to all subscribers (listening sockets).

Documentation: https://laravel.com/docs/8.x/broadcasting

1 like

Please or to participate in this conversation.