So I have been trying to set up ratchet for some time now. And have hit another snag. I have followed this tutorial http://socketo.me/docs/hello-world and everything seems to work on the local machine. however when I try to access them from a remote machine for testing purposes I cannot. Under the help and troubleshooting section it states to bind the chat-server program to 0.0.0.0 and I have done this to no avail. currently I have it running on port 9680 because 80 and 8080 are inuse on the system. (which is running an apache server) any help or suggestions on how to solve this connection issue would be much appreciated as I cannot continue with my project until I can access the Websockets remotely. I am fairly new to server administration so my knowledge of how to set this up is fairly slim. Thanks in advance!
You actually shouldn't bind your WebSocket server to 0.0.0.0 in production. In the context of servers, 0.0.0.0 means "all IPv4 addresses on the local machine". So say your server has a public IP address of 1.1.1.1 and a local/private IP address of 192.168.0.1, then this means an application bound to 0.0.0.0 will be reachable from both IPs (at least to whatever can route to those addresses). Which, typically, in a production setup, is not something you want. Normally, you want to bind to specific IP addresses on specific network interfaces, because you know exactly what your host will listen on.
The other gotchyas you want to look out for, is that binding to the public interface usually requires root privileges. Trying to do so without elevated privileges will usually result in an error opening the TCP socket. There's also the address is already in use problem, which can be solved by making sure you have SO_REUSEADDR
set on the socketopt (though, I'm fairly certain Ratchet does this for you by default). Additionally, if you're running SELinux, there's always the possibility that you're policy won't allow listening on that port. Then there's the firewall network configuration issues where either your firewall or some part of your network hardware is blocking the port.
The other draw back to having a multi-tenancy server, is that if you want to serve HTTP traffic both from your Apache httpd webserver as well as your PHP WebSocket server, you can't bind both to the same port on the same IP without putting a reverse proxy in front of them. In fact, this is what Ratchet recommends for production in their documentation.
The general idea is to have a reverse proxy like HAProxy, bound to the public IP listening on port 80/443, and then configure it route specific traffic either to your PHP WebSocket server (which will probably be listening on the local loopback or local network interface) or to your Apache httpd webserver depending on say a specific set of routes or some cookie, for example.