0

I'm currently using laravel-echo-server and websockets (socket.io) to broadcast events to my React application that is on a separate server.

As far as it looks, everything set up on the back end and front end are correct. The only issue I'm running into is not being able to connect to websockets (https://api.mysite.com:6001/socket.io/?EIO=4&transport=websocket). I'm getting ERR_CONNECTION_REFUSED.

I'm trying to figure out how I can allow a user to hit port 6001 over HTTPs on an apache server.

pbrune
  • 348
  • 1
  • 17
  • `ERR_CONNECTION_REFUSED` usually means that port is closed by firewall in the server side, so ask server sysadmin about it to unblock it – masterguru Dec 22 '21 at 00:15
  • @masterguru I am the sysadmin as well. Whenever I run ufw status, it appears that the port is already open: 6001/tcp ALLOW Anywhere 6001 ALLOW Anywhere 6001 (v6) ALLOW Anywhere (v6) 6001/tcp (v6) ALLOW Anywhere (v6) – pbrune Dec 22 '21 at 00:44
  • what version of socket.io are you using. – Michael Mano Dec 22 '21 at 01:24
  • Then try to telnet that port from that client machine: `telnet api.mysite.com 6001` and see if it connects. If yes then I was wrong. If not then you should fix this issue, that could be firewall again (check client side too) or maybe the service is not running (also check PORT status with `netstat -anp | grep 6001` to know if it in LISTEN status in server machine) – masterguru Dec 22 '21 at 05:50
  • Did you use `ProxyPass`? If yes, provide the configs you had done. – s.abbaasi Jan 06 '22 at 12:07
  • @s.abbaasi `ProxyPass /socket.io http://127.0.0.1:6001/socket.io/ ProxyPassReverse /socket.io http://127.0.0.1:6001/socket.io/` – pbrune Jan 06 '22 at 16:04
  • @pbrune remove the last / and try again. – s.abbaasi Jan 09 '22 at 08:59

1 Answers1

0

The only way i made it works was the following:

Step 1: Since i was using AWS i had to open the port 6001 (because i was using the default port used by laravel-websocket, you may open whatever port you want to use) by adding an inbound rule on the EC2 Security Groups configuration.

Step 2: Run in ssh console the command php artisan websocket:serve.

Step 3: If you want to make sure that the process will keep running always, you can install Supervisor.

Supervisor is a client/server system which will help you to keep running the websocket server created with the command.

I hope this can help you or other developers who reach here with the same problem.

References

lerichard_v
  • 401
  • 3
  • 8