title: Configure proxy setting for client node app accesses Azure ServiceBus with Azure SDK for Node
body: <p>I used the Azure SDK for node to create a client app to send and receive data to an Azure Service Bus Topics. The app runs fine with direct connection from my device to Azure cloud.  For enterprise environment, the device and client app must be run behind a firewall.  </p>
  
  <pre><code>  +---------+        +------------+         +-------------------+
    | Device  |   &lt;=&gt;  | HTTP Proxy |   &lt;=&gt;   | Azure SB endpoint |
    +---------+        +------------+         +-------------------+     
  </code></pre>
  
  <p>The Azure SDK ServiceClient code shows that it would automatically use the proxy setting from the environment variable -</p>
  
  <pre><code> HTTPS_PROXY=http://&lt;proxy-server&gt;:&lt;proxy port&gt;.  
  </code></pre>
  
  <p>I set the environment variable as such and it did not work. The connection failed on the SDK calls with: </p>
  
  <pre><code>Error: tunneling socket could not be established, cause=socket hang up
  </code></pre>
  
  <p>I used the 'azure-sdk-for-node\examples\samples\sbtopics.js' to test with proxy, it failed the same way. </p>
  
  <p>I tried to modify the default proxy and it did not fix the problem. 
  ...</p>
  
  <pre><code>var serviceBusClient = azure.createServiceBusService(azureSBSASStr);
  var defaultProxy = serviceBusClient.proxy;  // get the default proxy
  var auth = 'Basic ' + new Buffer('username:password').toString('base64');
  
  // override default
  defaultProxy.auth = auth;
  defaultProxy.rejectUnauthorized = false;
  defaultProxy.secureOptions = constants.SSL_OP_NO_TLSv1_2;  // also used SSL_OP_NO_SSLv3
  defaultProxy.strictSSL = false;
  
  // set the proxy
  serviceBusClient.setProxy(defaultProxy);
  
  // call to Service Bus SDK API resulted proxy connection failed
  </code></pre>
  
  <ul>
  <li>I have other node app that successfully communicates to other clouds through a http tunneling with the similar above http options with this same proxy server. </li>
  </ul>
  
  <p>Has anyone successfully got the Azure SDK for node to work with proxy?  Is there any other proxy configuration that I need to specify? </p>
  
  <p>Thx,  </p>