Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: socket hang up with 15.7.0 or newer #37510

Closed
SFx2018 opened this issue Feb 24, 2021 · 10 comments
Closed

Error: socket hang up with 15.7.0 or newer #37510

SFx2018 opened this issue Feb 24, 2021 · 10 comments
Labels
http Issues or PRs related to the http subsystem.

Comments

@SFx2018
Copy link

SFx2018 commented Feb 24, 2021

using https://github.com/mattcg/socks5-https-client combined with request library with node v15.7.0 or newer gives me "Error: socket hang up", with 15.6.0 everything is fine.

@ronag
Copy link
Member

ronag commented Feb 25, 2021

Please provided a minimal repro example.

@ronag ronag added the http Issues or PRs related to the http subsystem. label Feb 25, 2021
@SFx2018
Copy link
Author

SFx2018 commented Feb 25, 2021

works with v15.6.0, doesn't work with v15.10.0 - Error: socket hang up

I filled it with free socks5 proxy.

const request = require('request');
const Agent = require('socks5-https-client/lib/Agent');

let ip = {
	url: "https://api.myip.com",
	agentClass: Agent,
	agentOptions: {
		socksHost: '91.215.152.251',
		socksPort: 1080,
		socksUsername: '',
		socksPassword: '',
	},
	json: true
}

request(ip, function (error, response, body) {
	if (body) {
		console.log(body);
	} else {
		console.log(error);
	}
});

@ronag
Copy link
Member

ronag commented Apr 25, 2021

Sorry but the sample is unrunnable:

Error: SOCKS connection failed. Network unreachable.
    at Socket.<anonymous> (/Users/ronagy/GitHub/public/tmp/node_modules/socks5-client/lib/Socket.js:246:25)
    at Object.onceWrapper (node:events:483:26)
    at Socket.emit (node:events:376:20)
    at addChunk (node:internal/streams/readable:311:12)
    at readableAddChunk (node:internal/streams/readable:286:9)
    at Socket.Readable.push (node:internal/streams/readable:225:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:192:23)

@ronag
Copy link
Member

ronag commented Apr 25, 2021

Tried to repro without request (which is no longer maintained):

const https= require('http')
const Agent = require('socks5-https-client/lib/Agent');

https.request({
  hostname: 'api.myip.com',
  method: 'GET',
  protocol: 'https:',
  agent: new Agent({
    socksHost: '195.123.240.73',
    socksPort: 1080,
    socksUsername: '',
    socksPassword: '',
  })
}, (err, res) => {
  if (err) {
    throw err
  }
  console.error(res.statusCode)
  let body = ''
  res.on('data', (buf) => {
    body += buf
  }).on('end', () => {
    console.error(body)
  })
})

It's just stuck. Not Node related.

@ronag
Copy link
Member

ronag commented Apr 25, 2021

I can confirm it works with Node v15.5.1 but not Node v16.

socks5 seems to be messing with Node internals. I think we need help from the package developer to debug this.

@mattcg
Copy link

mattcg commented May 28, 2021

Hi @aicanfly I am interested in fixing this but am busy on some other projects. Would you be willing to submit a PR?

@benjamingr
Copy link
Member

@aicanfly there are several companies like nearForm that offer paid development services and can do this sort of fix. I am not sure if @ronag or @mcollina (or any other stream maintainers) are up for working on this but you are welcome to shoot them an email to discuss. It's a pretty typical/common format.

@wintercounter
Copy link

Had the same issue, switched to socks-proxy-agent, works fine for me.

@a7md0
Copy link

a7md0 commented Oct 8, 2022

Issue still persisting

node --version
v16.13.2

@bnoordhuis
Copy link
Member

Since it appears to be an issue with the library and not node itself, I'm going to close out this issue as non-actionable.

@bnoordhuis bnoordhuis closed this as not planned Won't fix, can't repro, duplicate, stale Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

No branches or pull requests

8 participants
@bnoordhuis @mattcg @wintercounter @benjamingr @ronag @a7md0 @SFx2018 and others