title: node js request proxy
body: <p>I send a request through a proxy and always receive such a response</p>
  
  <pre><code>tunneling socket could not be established, cause=read ECONNRESET
  </code></pre>
  
  <p>or</p>
  
  <pre><code>tunneling socket could not be established, cause= socket hang up
  </code></pre>
  
  <p>My code</p>
  
  <pre><code>      let settings = {
      url: `url`,
      headers: {
        'Connection': 'keep-alive',
        'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36"
      },
      method: 'POST',
      proxy: `http://${ip}:${port}`,
      strictSSL: false
    }
  request.request(settings, (err, response, body) =&gt; {
   // err here
  })
  </code></pre>
  
  <p>what am I doing wrong ?</p>
  
  <p>Now this error : Error: Tunnel creation failed. Socket error: Error: read ECONNRESET</p>
  
  <p>My code: </p>
  
  <pre><code>  const request = require('request'),
    proxyingAgent = require('proxying-agent');
  </code></pre>
  
  <p>;</p>
  
  <pre><code>let settings = {
      url: url,
      headers: {
        'Connection': 'keep-alive',
        'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36"
      },
      method: 'POST',
      // proxy: `http://${obj.proxy[obj.proxyIdx]}`,
      agent: proxyingAgent.create(`http://${obj.proxy[obj.proxyIdx]}`, url),
    }
  </code></pre>