3

I'm trying to use stunnel with wss on my site but when I try to connect I always get:

WebSocket connection to 'wss://www.soinfit.com:8443/' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT

My socket is running on port 8080 as this:

use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use MyApp\Chat;

require dirname(__DIR__) . '/vendor/autoload.php';

$server = IoServer::factory(
    new HttpServer(
        new WsServer(
            new Chat()
        )
    ),
    8080
);

$server->run();

My stunnel config is:

debug = 4
output = /var/log/stunnel4/websocket.log

socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1

cert = /etc/ssl/private/47f2ad52d70c0.crt
key = /etc/ssl/private/soinfit.key

[websocket]
accept = 8443
connect = 8080

I'm using Chrome to connect and I'm using this code:

try {
    conn = new WebSocket('wss://www.soinfit.com:8443');
    conn.onclose = function (e) {

    }
    conn.onopen = function(e) {
        console.log("test");
    };

} catch (error) {
    console.log(error);
}

There is nothing in the log file. What am I doing wrong? Thanks.

John Hascall
  • 9,176
  • 6
  • 48
  • 72
dasdasd
  • 1,971
  • 10
  • 45
  • 72
  • 1
    There are many factors that may contribute to this problem. I remember a while back when I tried to play around with WS it turned out there was a problem with resolving names so if you have your server listen on its IP but you connect to the domain that is supposed to resolve to that IP the connection failed. Additionally there may be firewalls in your network that block the connection, be sure to check if your ports are open, there are number of online tools that could help. – php_nub_qq Sep 05 '15 at 10:52

0 Answers0