mattcg / socks5-http-client

SOCKS v5 HTTP client implementation in JavaScript for Node.js.
254 stars 27 forks source link

This package won't work in node v0.11.x #8

Closed hanzhao closed 9 years ago

hanzhao commented 9 years ago

It receive no messages from socks without error messages.

hanzhao commented 9 years ago

The version of node I'm using is v0.11.13.

mattcg commented 9 years ago

Hey @Magimagi, thanks for filing :)

Does it just hang until the connection times out? Could you paste the code you're using to make the connection?

hanzhao commented 9 years ago
~/shttptest$ cat app.js
shttp = require('socks5-http-client');
options = {
  hostname: '110.90.118.124',
  port: 80,
  path: '/',
  method: 'GET',
  socksHost: '127.0.0.1',
  socksPort: 7890,
}
request = shttp.request(options, function(res) {
  console.log('STATUS: ' + res.statusCode);
  console.log('HEADERS: ' + JSON.stringify(res.headers));
  res.setEncoding('utf8');
  res.on('data', function (chunk) {
    console.log('BODY: ' + chunk);
  });
});
request.end();

~/shttptest$ nvm use v0.10.33
Now using node v0.10.33

~/shttptest$ node app.js 
STATUS: 200
HEADERS: {"date":"Wed, 05 Nov 2014 17:23:20 GMT","server":"Apache/2.2.15","last-modified":"Fri, 17 Feb 2012 06:18:32 GMT","etag":"\"140687-56-4b922e9fa8f66\"","accept-ranges":"bytes","content-length":"86","connection":"close","content-type":"text/html; charset=UTF-8"}
BODY: <html>
<script language="javascript">
self.location='/OnlineJudge';
</script>
</html>

~/shttptest$ nvm use v0.11.14
Now using node v0.11.14
~/shttptest$ node app.js 
^C

I have a socks5 proxy listening on 127.0.0.1:7890. When using Node 0.11.x instead of 0.10.33, it hang for a long time. Codes list above.

reverofevil commented 9 years ago

Were there any news regarding this issue? Default tor.js example, Node 0.11.14, Windows 7.

pmarkert commented 9 years ago

I can confirm that this issue is still happening. I'm using this library as part of hyperpotamus and I noticed this same issue just the other day. Now that node 0.12.0 is out, I suspect this is a bigger issue than before when it was only affecting the 0.11.x development branches.

I can reproduce the issue using the build-in tor.js example:

$ time node tor.js | wc -l
     735

real    0m0.729s
user    0m0.064s
sys 0m0.021s

$ port activate nodejs @0.12.0_0+python27+ssl
--->  Computing dependencies for nodejs
--->  Deactivating nodejs @0.10.33_0+python27+ssl
--->  Cleaning nodejs
--->  Activating nodejs @0.12.0_0+python27+ssl
--->  Cleaning nodejs

$ time node tor.js | wc -l
^C

real    0m52.630s
user    0m0.071s
sys 0m0.018s

NOTE: In this instance, I ran the output of tor.js through wc -l because it was rather verbose. You can see from the second run that I aborted the script after 52 seconds of no activity, but I have waited longer with no results.

reverofevil commented 9 years ago

@pmarkert Consider testing in io.js. They have versions of https and fs that weren't broken, yet there are generators and other ES6 features.

mattcg commented 9 years ago

Thanks for all the bug reports and sorry it took so long to fix this. Try v1.0.0.