Reputation: 403
I am using beyondcode/laravel-websockets to implement web sockets functionality in Laravel. I am using supervisor in Apache server to run processes for database queues and web sockets. It was working fine until one day I realized that It has stopped working. I haven't made any changes to supervisor.conf file.
This is my supervisor.conf
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/webroot/ROOT/artisan queue:work --tries=3
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=apache
redirect_stderr=true
stdout_logfile=/var/www/webroot/ROOT/worker.log
stopwaitsecs=3600
startsecs=0
[program:websockets]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/webroot/ROOT/artisan websockets:serve
numprocs=1
autostart=true
autorestart=true
user=apache
When I try to start all supervisor processes using command supervisorctl start all
, I get the following output:
laravel-worker:laravel-worker_00: started
websockets:websockets_00: ERROR (spawn error)
Based on this, I manually started the web sockets from my root directory using php artisan websockets:serve
and I got below error:
Starting the WebSocket server on port 6001...
RuntimeException
Failed to listen on "tcp://0.0.0.0:6001": Address already in use (EADDRINUSE)
at vendor/react/socket/src/TcpServer.php:184
180▕ // @link https://3v4l.org/3qOBl
181▕ $errno = SocketServer::errno($errstr);
182▕ }
183▕
➜ 184▕ throw new \RuntimeException(
185▕ 'Failed to listen on "' . $uri . '": ' . $errstr . SocketServer::errconst($errno),
186▕ $errno
187▕ );
188▕ }
+17 vendor frames
18 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
As mentioned in the exception, the port I am using for web sockets i.e. 6001
is already in use. I listed the used ports using the command netstat -tulpn
and it shows that 6001
port is being used by php. This is the output:
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 23974/php
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::111 :::* LISTEN -
tcp6 0 0 :::80 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
udp 0 0 0.0.0.0:111 0.0.0.0:* -
udp 0 0 0.0.0.0:749 0.0.0.0:* -
udp6 0 0 :::111 :::* -
udp6 0 0 :::749 :::* -
I killed the process using kill 23974
but it reopens quickly and uses the same port again automatically. I am not being able to figure what exactly is using this port. I tried reconfiguring, restarting supervisor, redeploying my code etc. but nothing worked. What might be the possible issues here?
Upvotes: 1
Views: 869