Answer the question
In order to leave comments, you need to log in
How to make a websocket accessible from the internet?
There is a websocket in php using the ratchet library, only the connection code is probably interesting here:
require 'vendor/autoload.php';
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
require 'php/process.php';
// Run the server application through the WebSocket protocol on port 8080
$app = new Ratchet\App("localhost", 8080, '0.0.0.0', $loop);
$app->route('/chat', new Chat, array('*'));
$app->run();
new WebSocket("ws://localhost:8080/chat")
ProxyPass /ws/ ws://localhost:8080/chat
ProxyPassReverse /ws/ ws://localhost:8080/chat
new WebSocket("ws://localhost/ws/")
location /chat/ {
proxy_pass http://localhost:8080/chat;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
new WebSocket("ws://192.168.1.63/chat/")
Answer the question
In order to leave comments, you need to log in
forward the port through the router where the web socket works.
Then access the web socket, from the outside, like:
new WebSocket("ws://2.60.19.4/chat/")
where 2.60.19.4 is your external ip, also use it with port 8080 or 80, as already required.
Check what is listening on the forwarded port 8080 and 80 of the Apache or nginx config that proxies the web-socket. times 404, then the request goes to the wrong vhost.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question