Skip to content

Error: socket hang up with 15.7.0 or newer #37510

Closed as not planned
Closed as not planned

Description

@SFx2018

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.

Activity

  1. ronag commented on Feb 25, 2021

    @ronag
    Member

    Please provided a minimal repro example.

  2. added
    httpIssues and PRs related to the http subsystem.
    on Feb 25, 2021
  3. SFx2018 commented on Feb 25, 2021

    @SFx2018
    Author

    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);
    	}
    });
    
  4. ronag commented on Apr 25, 2021

    @ronag
    Member

    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)
  5. ronag commented on Apr 25, 2021

    @ronag
    Member

    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.

  6. ronag commented on Apr 25, 2021

    @ronag
    Member

    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.

  7. mattcg commented on May 28, 2021

    @mattcg

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

  8. benjamingr commented on Jul 1, 2021

    @benjamingr
    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.

  9. wintercounter commented on Aug 17, 2021

    @wintercounter

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

  10. a7md0 commented on Oct 8, 2022

    @a7md0

    Issue still persisting

    node --version
    v16.13.2
  11. bnoordhuis commented on Oct 9, 2022

    @bnoordhuis
    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues and PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions