DriveMond

80% Offer Rate Sticker Mobile
80% Offer Rate Sticker
00 Hour
00 Min
00 Sec
80% Offer Rate Sticker Mobile
80% Offer Rate Sticker

Configure WebSocket Server

Starting the WebSocket Server #

Once you have configured your WebSocket apps, you can start the Laravel Reverb by issuing the artisan command:

php artisan reverb:start

Using a different port #

The default port of the Laravel Reverb is 6001. You may pass a different port to the command using the –port option.

php artisan reverb:start --port=6015

This will start listening on port 6015.

Keeping the socket server running with supervisord #

The reverb:start daemon needs to always be running in order to accept connections. This is a prime use case for supervisor, a task runner on Linux.

First, make sure the supervisor is installed.

# On Debian / Ubuntu
apt install supervisor

# On Red Hat / CentOS
yum install supervisor
systemctl enable supervisord

Once installed, add a new process that supervisor needs to keep running. You place your configurations in the /etc/supervisor/conf.d (Debian/Ubuntu) or /etc/supervisord.d (Red Hat/CentOS) directory.

Within that directory, create a new file called websockets.conf.

[program:websockets]
command=/usr/bin/php /home/root/laravel-websockets/artisan reverb:start
numprocs=1
autostart=true
autorestart=true
user=root

Once created, instruct the supervisor to reload its configuration files (without impacting the already running supervisor jobs).

supervisorctl update
supervisorctl start websockets

Your echo server should now be running (you can verify this with supervisorctl status). If it were to crash, the supervisor will automatically restart it.

Please note that, by default, the supervisor will force a maximum number of open files onto all the processes that it manages. This is configured by the minfds parameter in supervisord.conf.

If you want to increase the maximum number of open files, you may do so in /etc/supervisor/supervisord.conf (Debian/Ubuntu) or /etc/supervisord.conf (Red Hat/CentOS):

[supervisord]
minfds=10240; (min. avail startup file descriptors;default 1024)

After changing this setting, you’ll need to restart the supervisor process (which in turn will restart all your processes that it manages).

Configuration in Admin Panel #

After configuring all the settings above, update the Websocket Port.