title: Unable to connect to a websocket
body: <p>I created a PHP websocket using <a href="http://socketo.me/">Ratchet</a>. This Websocket is running on port <code>8080</code> of my internal server <code>10.0.4.160</code>.</p>
  
  <p>I am trying to connect to it from a website that have SSL enabled "aka using https protocol." </p>
  
  <p>When attempting to connect to the websocket form a FireFox browser, I get security issues from the browser because I am mixing between secured/non-secured connection. This is the error that I see in the javascript's console.</p>
  
  <blockquote>
    <p>SecurityError: The operation is insecure.</p>
  </blockquote>
  
  <p>To fix the security issue I created a <a href="https://www.stunnel.org/index.html">stunnel</a> proxy which allows me to accept the connection on  <code>10.0.4.160:58443</code> and connect it to port <code>127.0.0.1:8080</code>. This secure tunnel should allow me to keep my connection to the websocket secured and bypass the browser's security check.</p>
  
  <p>However, every time I attempt to connect to the websocket I get an error</p>
  
  <blockquote>
    <p>WebSocket connection to 'wss://10.0.4.160:58443/' failed: Error in
    connection establishment: net::ERR_TIMED_OUT</p>
  </blockquote>
  
  <p>This is the jQuery script that is used to connect to the websocket</p>
  
  <pre><code>&lt;script&gt;
  
      $(function(){
          if ("WebSocket" in window)
          {
              var conn = new WebSocket('wss://10.0.4.160:58443');
  
              conn.onopen = function(e) {
                  console.log("Connection established!");
                  showMessage('Connected', 0);
              };
  
              conn.onmessage = function(e) {
                  console.log(e.data);
                  showMessage(e.data, 1);
              };
  
              conn.onclose = function(e) {
                  console.log(e.code);
                  console.log(e.reason);
              };              
  
              conn.onerror = function(e) {
                  console.log(e);
              };      
  
          } else {
              console.log('Your browser does not support Websocket!');
          }
  
          function showMessage(msg, append){
              if(append){
                  $('#status').append('&lt;br&gt;' + msg);
                  return;
              }
  
              $('#status').text(msg);
          }
      });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is my current stunnel configuration</p>
  
  <pre><code>[websockets]
  client = yes
  accept = 58443
  connect = 8080
  verify = 2
  CAfile = ca-certs.pem
  debug = 7
  OCSPaia = yes
  </code></pre>
  
  <p>How can I connect to the websocket from my browser?
  Thank you</p>