code-settings-sync: Extension is not working behind a proxy

Visual Studio Code Version : [ 1.4 ] Code Sync Settings Version : [ last on 2016-08-08 ] Operating System : [ Windows 7 ]

Error: getaddrinfo ENOTFOUND api.github.com api.github.com:443
    at global.sendError (C:\Users\peninni2\.vscode\extensions\Shan.code-settings-sync-1.6.3\node_modules\github4\lib\index.js:753:19)
    at C:\Users\peninni2\.vscode\extensions\Shan.code-settings-sync-1.6.3\node_modules\github4\lib\index.js:762:29
    at callCallback (C:\Users\peninni2\.vscode\extensions\Shan.code-settings-sync-1.6.3\node_modules\github4\lib\index.js:639:17)
    at ClientRequest.<anonymous> (C:\Users\peninni2\.vscode\extensions\Shan.code-settings-sync-1.6.3\node_modules\github4\lib\index.js:710:17)
    at emitOne (events.js:90:13)
    at ClientRequest.emit (events.js:182:7)
    at TLSSocket.socketErrorListener (_http_client.js:295:9)
    at emitOne (events.js:90:13)
    at TLSSocket.emit (events.js:182:7)
    at connectErrorNT (net.js:996:8)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 5
  • Comments: 26 (10 by maintainers)

Most upvoted comments

I have published the 2.3.4 version with proxy support.

Hi @shanalikhan, to solve this problem, just add proxy into options when you create node-github instance, like:

new GitHubApi({ proxy: "http://127.0.0.1:1080" // ss proxy for example. })

as the node-github is using https-proxy-agent to handle proxy in its httpSend function which is used to handle Gist/GitHub api.

So, you can just save proxy settings into syncSettings.json file, and read it when your ext is activated.

I’ve tested in my syncing ext and it worked well. Hope this would help!

You could e.g. use Fiddler (http://www.telerik.com/fiddler) to setup a test environment for proxy. This way could can even look which requests where sent to the proxy.

@shanalikhan 😄 It seems that this only solve the Gist proxy issue, but yes you can also use https-proxy-agent with https module to solve the same problem in your Util.HttpPostJson function 😃

Here’s an example:

var https = require("https");
var HttpsProxyAgent = require("https-proxy-agent");
var proxy = "http://127.0.0.1:1080";
var agent = new HttpsProxyAgent(proxy);

// then add this agent into your options file like:
var options: https.RequestOptions = {
    host: item.hostname,
    port: +item.port,
    path: item.path,
    method: 'POST',
    headers: newHeader,
    agent: agent
};

I found this solution here reference.