Unable to connect to Tor Socket (Error: Socket Closed)
kaue opened this issue · 5 comments
kaue commented
May 09 13:49:21.000 [notice] Tor 0.2.6.10 (git-58c51dc6087b0936) opening log file.
May 09 13:49:21.028 [notice] Tor v0.2.6.10 (git-58c51dc6087b0936) running on Linux with Libevent 1.4.13-stable, OpenSSL 1.0.1e-fips and Zlib 1.2.3.
May 09 13:49:21.028 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
May 09 13:49:21.028 [notice] Read configuration file "/tor/etc/tor/torrc".
May 09 13:49:21.031 [notice] Opening Socks listener on 127.10.254.1:9050
May 09 13:49:21.000 [notice] Parsing GEOIP IPv4 file /tor/share/tor/geoip.
May 09 13:49:21.000 [notice] Parsing GEOIP IPv6 file /tor/share/tor/geoip6.
May 09 13:49:21.000 [notice] We were built to run on a 64-bit CPU, with OpenSSL 1.0.1 or later, but with a version of OpenSSL that apparently lacks accelerated support for the NIST P-224 and P-256 groups. Building openssl with such support (using the enable-ec_nistp_64_gcc_128 option when configuring it) would make ECDH much faster.
May 09 13:49:21.000 [notice] Bootstrapped 0%: Starting
May 09 13:49:21.000 [notice] Bootstrapped 5%: Connecting to directory server
May 09 13:49:21.000 [notice] Bootstrapped 80%: Connecting to the Tor network
May 09 13:49:21.000 [notice] Bootstrapped 85%: Finishing handshake with first hop
May 09 13:49:22.000 [notice] Bootstrapped 90%: Establishing a Tor circuit
May 09 13:49:23.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working.
May 09 13:49:23.000 [notice] Bootstrapped 100%: Done
var tr = require('tor-request');
tr.setTorAddress('127.10.254.1', 9050);
tr.request('https://api.ipify.org', function (err, res, body) {
if(err) console.log(err);
if (!err && res.statusCode == 200) {
console.log("Your public (through Tor) IP is: " + body);
}
});
Result:
Error: Socket Closed
at Socket.<anonymous> (/node_modules/socks/lib/socks-client.js:61:20)
at Object.onceWrapper (events.js:293:19)
at emitOne (events.js:96:13)
at Socket.emit (events.js:191:7)
at TCP._handle.close [as _onclose] (net.js:511:12)
kaue commented
I was able to fix the issue changing the SocksPort
var on etc/tor/torrc
to 127.10.254.1:auto
.
talmobi commented
Hmm, so this was not an issue with tor-request
but rather tor's own configuration?
Thanks for the explanation and solution -- could perhaps add a heads-up to the README or something for common issues like these.
talmobi commented
After installing tor with brew -- did you also start it by running `tor` in
the terminal? on Mac the tor daemon doesn't start automatically.
…On Thu, Oct 19, 2017 at 11:14 PM, 360Disrupt ***@***.***> wrote:
I'm having the same issue:
var tr = require('tor-request');
var request = require('request');
var url = 'https://google.com/';
//200
request.get(url).on('response', function(res) {
var data;
if (res.statusCode === 200) {
data = "";
res.on('data', function(chunk) {
return data += chunk;
});
return res.on('end', function() {
var err;
console.log("data", data);
});
} else {
console.error(res.statusCode);
return null
}
}).on('error', function(err) {
console.error(err);
return err
});
//Error: Socket Closed
tr.request(url, function (err, res, body) {
if (!err && res.statusCode == 200) {
console.log("Body: " + body);
}
else if (res != undefined)
console.log(res.statusCode);
else
console.error(err);
});
I installed tor with brew on Mac OS X. What do I need to set here to get
it running (tried the above ip & localhost with auto).
tr.setTorAddress('127.10.254.1', 'auto');
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#11 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABZJh6fOZhslizCmZ8C0EK_ZguLJfAl2ks5st63AgaJpZM4NVqo5>
.
360disrupt commented
I forgot the start. I tried to delete the comment but you have been too fast, sorry. Thx