mattcg / socks5-client

SOCKS v5 client socket implementation in JavaScript for Node.JS.
Other
56 stars 31 forks source link

Incompatible with Node 4.2.1 #10

Closed dga711 closed 8 years ago

dga711 commented 8 years ago

Can't use it as an agent with request using Node 4.2.1 Example also doesnt work.

Proxy is a TOR proxy.

Edit: The issue is concerning socks5-http-client. But the problem seems to lie in this library.

dga711 commented 8 years ago

I'm no expert with this but one thing i saw while trying to debug: The last 2 bytes (Port) of the request to proxy are 0 80 . Shouldn't it be LOWBYTE HIGHBYTE?

But this is probably not what breaks it.

anderfjord commented 8 years ago

I've run into a similar (or perhaps the same) issue using this module with Tor. The error message I'm getting seems to have something to do with the use of stream.Writable.cork():

TypeError: socket.cork is not a function at ClientRequest.OutgoingMessage._flush (_http_outgoing.js:642:14) at _http_client.js:148:10 at Socks5ClientSocket.callSocketMethod (_http_client.js:513:7) at Socks5ClientSocket.g (events.js:260:16) at emitNone (events.js:67:13) at Socks5ClientSocket.emit (events.js:166:7) at Socks5ClientSocket.handleSocksConnectToHost (/usr/project_directory/node_modules/socks5-http-client/node_modules/socks5-client/lib/Socks5ClientSocket.js:135:7)

I'm not sure why cork() would be an issue, since I believe this was introduced in v0.12, which I was previously using without a problem.

I don't know if this is happening during socket connection (see this thread [https://github.com/nodejs/node/pull/2960#discussion_r41955893]), or during a write, though I have found that if I change self.writeable to false on line 131 of Socket.js [https://github.com/mattcg/socks5-client/blob/master/lib/Socket.js#L131], then I no longer have the issue.

anderfjord commented 8 years ago

Also, I'm using FreeBSD. Not sure sure if it has anything to do with FreeBSD's use of TCP_NOPUSH in place of Linux's use of TCP_CORK.

dga711 commented 8 years ago

Thanks for your input. I don't think its a problem with FreeBSD. I get the same error on Win10/2008R2 when running the examples from the socks5-http-client project.

mattcg commented 8 years ago

This should have been fixed by #11. Will you re-test please?

anderfjord commented 8 years ago

Installing the latest version (1.1.2) has fixed my problem. Thanks!

mattcg commented 8 years ago

Fantastic, thank you for reporting! :sparkling_heart: