title: How do I open a websocket connection to cloud from location behind corporate proxy
body: <p>I have a nodejs websocket server running in the cloud to which I can make a secured web socket connection from any location outside of corporate firewall.
   Now, how can I provide proxy information while creating a websocket connection from a resource behind corporate proxy (on-premise)? I am using this nodejs module from <a href="https://github.com/websockets/ws" rel="nofollow">https://github.com/websockets/ws</a>. </p>
  
  <p>I get EHOSTUNREACH error when I execute following code. Please note there is no vpn connection between cloud resource and the on premise resource. </p>
  
  <pre><code>**var wss = new WebSocket('wss://cloudserver:443', {
          rejectUnauthorized: false
      });**
  </code></pre>
  
  <p>With a sample code like below, I am able to make http connection to cloud from a resource behind corporate proxy using proxy information , but can't figure out how to make it work with the web sockets. </p>
  
  <pre><code>    **var Http = require('http');
  
      var req = Http.request({
          host: 'proxy',
          port: 8080,
          method: 'GET',
          path: 'http://cnn.com/' // full URL as path
      }, function (res) {
          res.on('data', function (data) {
              console.log(data.toString());
          });
      });
  
      req.end()
  
  **
  </code></pre>
  
  <p>I also looked at following <a href="http://blog.vanamco.com/proxy-requests-in-node-js/" rel="nofollow">http://blog.vanamco.com/proxy-requests-in-node-js/</a> and it seems to have what I need, but as I am new to nodejs I am somewhat lost here. </p>