You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I could successfully use the http json and xml clients using the HTTP_PROXY variable in either the environment or set in the options... Right now, I cannot do that... I'm getting the following:
{ [Error: tunneling socket could not be established, cause=Parse Error] code: 'ECONNRESET' }
@marcellodesales can you give source code with which you can reproduce this error? Please also include the OS, restify and Node.js versions you're using.
From another machine with Internet connection, it works as expected:
mdesales@ubuntu[05/29/201511:28:05]~/dev/isp(develop)$nodetest.js{url: 'http://petstore.swagger.io',name: 'Intuit-HTTP-Client',type: 'json',path: '/v2/pet/findByStatus?status=pending',headers: {Accept: 'application/json'}}[{"id":1432867554,"category":{"id":1432867554,"name":"dog"},"name":"hello kity with form updated","photoUrls":["http://foo.bar.com/1","http://foo.bar.com/2"],"tags":[{"id":1432867554,"name":"blank"}],"status":"pending"},{"id":10002,"category":{"id":20002,"name":"category test"},"name":"RUBY UNIT TESTING","photoUrls":[],"tags":[{"id":30002,"name":"tag test"}],"status":"pending"},{"id":1432881297,"category":{"id":1432881297,"name":"dog"},"name":"hello kity with form updated","photoUrls":["http://foo.bar.com/1","http://foo.bar.com/2"],"tags":[{"id":1432881297,"name":"blank"}],"status":"pending"},{"id":11020,"category":{"id":56,"name":"sample category name2"},"name":"Csharp test","photoUrls":["sample photoUrls"],"tags":[{"id":11020,"name":"sample tag name2"}],"status":"pending"},{"id":6,"category":{"id":1,"name":"Dogs"},"name":"Dog 3","photoUrls":["url1","url2"],"tags":[{"id":1,"name":"tag3"},{"id":2,"name":"tag4"}],"status":"pending"},{"id":1432904252150,"name":"woofwoof jones","photoUrls":[],"tags":[],"status":"pending"}]
I have another example with the Request module that works just fine...
I see this as well. I don't quite get how to use an http proxy with restify (2.8.5 and 3.0.3). I hope I'm just missing something. Here's a gist showing how I'm trying to do this: https://gist.github.com/BryanDonovan/a7c02321b1af1eb216b2
In that file I can easily use request.js to make a request through a proxy server (also in that file), and request.js uses the same tunnel-agent npm as restify under the hood, so I must be missing a config option somewhere. Is the syntax something like this?
After quite a bit of debugging, I believe the issue is from our use of tunnel-agent, which has diverged a lot from the request library which it sprang from, as well as not setting the host and port of the outgoing request appropriately. Until we can get a fix out, you can do these two things:
When setting up your client do the following, set the agent to false and parse the proxy url:
@micahr Unfortunately this did not change... Here's what I tried...
# root at pppdc9prd5pq in /export/home/mdesales/sp-http-client on git:master x [13:35:41]
$ cat node_modules/restify/package.json | grep version
"version": "3.0.3",
Proxy
# root at pppdc9prd5pq in /export/home/mdesales/sp-http-client on git:master x [13:24:40]
$ echo $HTTP_PROXY
http://qypprdproxy02.ie.intuit.net:80
Changes
I applied the change from aa40eb8 but it seems that it does not make any change...
$catnode_modules/restify/lib/clients/http_client.js|grepFIXING// CHANGE TO TRY FIXING PROXY as https://github.com/restify/node-restify/issues/813#issuecomment-118744309console.log(this);if(this.proxy){opts.host=this.proxy.hostname;opts.port=this.proxy.port;}
I also change the cline above as follows:
varrestify=require("restify");varurl=require("url");varquery="?status=pending";varoptions={};options.url="http://petstore.swagger.io";options.name=options.name||"xxxx-HTTP-Client";options.type=options.type||"json";options.path="/v2/pet/findByStatus"+query;options.headers={Accept: "application/json"};// PROXY SUPPORToptions.agent=false;options.proxy=url.parse(process.env.HTTP_PROXY);varclient=restify.createClient(options);// HTTP GET request. Taking HTTP_PROXY or https_proxy (or any case)client.get(options,function(err,req,res,data){if(err){console.log(err);return;}client.close();console.log(JSON.stringify(data));});
Running the test class
I also print the this object from the client change
$timecurl"http://petstore.swagger.io/v2/pet/findByStatus?status=pending"[{"id":9527,"name":"Kitty","photoUrls":[],"tags":[],"status":"pending"},{"id":1435804807,"category":{"id":1435804807,"name":"dog"},"name":"hello kity with form updated","photoUrls":["http://foo.bar.com/1","http://foo.bar.com/2"],"tags":[{"id":1435804807,"name":"blank"}],"status":"pending"},{"id":1435805127,"category":{"id":1435805127,"name":"dog"},"name":"hello kity with form updated","photoUrls":["http://foo.bar.com/1","http://foo.bar.com/2"],"tags":[{"id":1435805127,"name":"blank"}],"status":"pending"},{"id":1435805202,"category":{"id":1435805202,"name":"dog"},"name":"hello kity with form updated","photoUrls":["http://foo.bar.com/1","http://foo.bar.com/2"],"tags":[{"id":1435805202,"name":"blank"}],"status":"pending"},{"id":1435819364,"category":{"id":1435819364,"name":"dog"},"name":"hello kity with form updated","photoUrls":["http://foo.bar.com/1","http://foo.bar.com/2"],"tags":[{"id":1435819364,"name":"blank"}],"status":"pending"},{"id":1435819505,"category":{"id":1435819505,"name":"dog"},"name":"hello kity with form updated","photoUrls":["http://foo.bar.com/1","http://foo.bar.com/2"],"tags":[{"id":1435819505,"name":"blank"}],"status":"pending"},{"id":10002,"category":{"id":20002,"name":"category test"},"name":"RUBY UNIT TESTING","photoUrls":[],"tags":[{"id":30002,"name":"tag test"}],"status":"pending"},{"id":1436176466,"category":{"id":1436176466,"name":"dog"},"name":"hello kity with form updated","photoUrls":["http://foo.bar.com/1","http://foo.bar.com/2"],"tags":[{"id":1436176466,"name":"blank"}],"status":"pending"},{"id":1436176534,"category":{"id":1436176534,"name":"dog"},"name":"hello kity with form updated","photoUrls":["http://foo.bar.com/1","http://foo.bar.com/2"],"tags":[{"id":1436176534,"name":"blank"}],"status":"pending"},{"id":1436176890,"category":{"id":1436176890,"name":"dog"},"name":"hello kity with form updated","photoUrls":["http://foo.bar.com/1","http://foo.bar.com/2"],"tags":[{"id":1436176890,"name":"blank"}],"status":"pending"},{"id":1436177116,"category":{"id":1436177116,"name":"dog"},"name":"hello kity with form updated","photoUrls":["http://foo.bar.com/1","http://foo.bar.com/2"],"tags":[{"id":1436177116,"name":"blank"}],"status":"pending"},{"id":1436177156,"category":{"id":1436177156,"name":"dog"},"name":"hello kity with form updated","photoUrls":["http://foo.bar.com/1","http://foo.bar.com/2"],"tags":[{"id":1436177156,"name":"blank"}],"status":"pending"},{"id":1436177425,"category":{"id":1436177425,"name":"dog"},"name":"hello kity with form updated","photoUrls":["http://foo.bar.com/1","http://foo.bar.com/2"],"tags":[{"id":1436177425,"name":"blank"}],"status":"pending"}]curl "http://petstore.swagger.io/v2/pet/findByStatus?status=pending"
0.00suser0.00ssystem5%cpu0.054total
Potential improvements
As you don't check for cases, clients might not get this properly set... Some environments use the environment variable on its upper-case form HTTP_PROXY instead of http_proxy.
$catnode_modules/restify/lib/clients/http_client.js|grepproxyif(process.env.https_proxy){this.proxy=url.parse(process.env.https_proxy);}elseif(process.env.http_proxy){this.proxy=url.parse(process.env.http_proxy);}elseif(options.proxy){this.proxy=options.proxy;this.proxy=false;if(this.proxy){if(this.proxy.protocol==='https:'){if(this.proxy.protocol==='https:'){if(this.proxy){proxy: self.proxy,// CHANGE TO TRY FIXING PROXY as https://github.com/restify/node-restify/issues/813#issuecomment-118744309if(this.proxy){opts.host=this.proxy.hostname;opts.port=this.proxy.port;
@micahr I tried changing both options.path and options.url. None of them works... It looks like the URL is being parsed, so changing "options.path" DOES NOT HAVE ANY AFFECT...
Activity
yunong commentedon May 29, 2015
@marcellodesales can you give source code with which you can reproduce this error? Please also include the OS, restify and Node.js versions you're using.
marcellodesales commentedon May 29, 2015
Any connectivity to the Internet has to go through a HTTP_PROXY in my host... here are some info... I'm using latest restify...
The code was as follows:
The output of this works properly...
Going through the HTTP_PROXY, the connection just fails with the message above... I had tested this before and it used to work properly...
The first output is the set of environment variables... I removed all the others, but here's only the list of the PROXY ones...
The second output is the options used for the client... I'm assuming the HTTP PROXY is automatically used by the client...
From another machine with Internet connection, it works as expected:
I have another example with the Request module that works just fine...
thanks a lot for any help!
BryanDonovan commentedon Jun 28, 2015
I see this as well. I don't quite get how to use an http proxy with restify (2.8.5 and 3.0.3). I hope I'm just missing something. Here's a gist showing how I'm trying to do this: https://gist.github.com/BryanDonovan/a7c02321b1af1eb216b2
In that file I can easily use request.js to make a request through a proxy server (also in that file), and request.js uses the same
tunnel-agentnpm as restify under the hood, so I must be missing a config option somewhere. Is the syntax something like this?I also tried omitting the
proxyarg and setting myhttp_proxyenv var tohttp://127.0.0.1:5050but I get the same result either way:micahr commentedon Jun 29, 2015
Thank you for providing an example. I'll take a look and see if I can pinpoint the bug.
marcellodesales commentedon Jun 29, 2015
@micahr thanks for looking into this... I really need a patch for this! :( I'm glad to verify any patch you may have!
micahr commentedon Jul 6, 2015
After quite a bit of debugging, I believe the issue is from our use of tunnel-agent, which has diverged a lot from the request library which it sprang from, as well as not setting the host and port of the outgoing request appropriately. Until we can get a fix out, you can do these two things:
When setting up your client do the following, set the agent to false and parse the proxy url:
You will also need to apply the change from this (aa40eb8) commit, and you should be able to proxy, for now.
Let me know if those two things combined fixed your issue.
marcellodesales commentedon Jul 6, 2015
@micahr Unfortunately this did not change... Here's what I tried...
Proxy
Changes
I applied the change from aa40eb8 but it seems that it does not make any change...
I also change the cline above as follows:
Running the test class
I also print the
thisobject from the client changeCurl works
Potential improvements
As you don't check for cases, clients might not get this properly set... Some environments use the environment variable on its upper-case form
HTTP_PROXYinstead ofhttp_proxy.micahr commentedon Jul 6, 2015
Looks like your request path isn't being set to the full url you are trying to access.
Try setting your
options.pathtohttp://petstore.swagger.io/v2/pet/findByStatus?status=pendingfor your example above and see if that helps at all.marcellodesales commentedon Jul 6, 2015
@micahr I tried changing both
options.pathandoptions.url. None of them works... It looks like the URL is being parsed, so changing "options.path"DOES NOT HAVE ANY AFFECT...path change
URL change
marcellodesales commentedon Jul 19, 2015
@micahr Any news on this?
micahr commentedon Jul 20, 2015
Sorry, nothing yet. If you are blocked, I'd suggest using the request library for the time being.
marcellodesales commentedon Jul 20, 2015
Sounds good...
[-]tunneling socket could not be established: ECONNRESET when trying to use HTTP_PROXY[/-][+]Support HTTP_PROXY[/+]Create FEATURE_REQUESTS.md