Use the built-in web sockets server to receive real-time updates and notifications.
In this article, we will discuss how to configure the built-in Web Sockets server provided by the help desk. The Web Sockets server allows real-time communication between the server and the client (browser).
For this guide, we assume that the help desk is installed at
In order for the Web Socket server to listen on new connections, the
php artisan websockets:serve command should be executed at the root directory of the installation. Note that once the
websockets:serve command has started, it will continue to run until it is manually stopped or you close your terminal.
To keep the
websockets:serve process running permanently in the background, we will use the process monitor, Supervisor, to ensure that the built-in web sockets server worker does not stop running.
To enable the built-in web socket server, simply add
BROADCAST_DRIVER=builtin to the .env file, located at the root directory of your help desk application. Make sure there's only one
BROADCAST_DRIVER configuration on the file.
Supervisor is a process monitor for the Linux operating system, and will automatically restart your
websockets:serve process if it fails. To install Supervisor on Ubuntu, you may use the following command:
sudo apt-get install supervisor
Supervisor configuration files are typically stored in the
/etc/supervisor/conf.d directory. Within this directory, you may create any number of configuration files that instruct supervisor how your processes should be monitored. For example, let's create a
fullhelp.conf file that starts and monitors a
command=/usr/bin/php /var/www/fullhelp/live/artisan websockets:serve --port=6001
Make sure to replace
/var/www/fullhelp/live with the path to your own installation.
--port can also be changed based on your needs,
6001 is the default port used by the built-in web sockets server. If you select a port other than
6001, make sure to add
PUSHER_PORT=your-port to the .env file.
Once the configuration file has been created, you may update the Supervisor configuration and start the processes using the following commands:
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start fullhelp-ws-worker:*
For more information on Supervisor, consult the Supervisor documentation.
If you have configured HTTPS for your help desk software, it is also crucial to secure the WebSockets server. Adding SSL support is easy.
These are high-level instructions and should be adapted to each environment. In most cases, SSL is provided by Let's Encrypt, so we are going to use it as an example.
First, add the following settings to the .env file:
See the following example:
Once you add the certificate file paths, enable HTTPS for WebSocket connections by adding the following to the .env file:
The port 6001 will not work when using CloudFlare Proxy. Change it to one of the allowed secure ports, like 2053. Remember to update the supervisor configuration for the websocket:serve command and the .env file.
The built-in Web Sockets server may not work correctly for several reasons, the most common ones are:
BROADCAST_DRIVERconfiguration value, see the Enable the Built-In Web Socket Server section
Determining the real cause of a problem and the solution will vary considerably by what server is in use and the configurations.
Siempre puedes ponerte en contacto si no encuentras lo que estás buscando en nuestro centro de ayuda. ¡Te responderemos tan pronto sea posible!
Siempre puedes ponerte en contacto si no encuentras lo que estás buscando en nuestro centro de ayuda. ¡Te responderemos tan pronto sea posible!Contáctenos