Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

181
Visualizações
How can I find out whether Node.js HTTPS request error was caused by a missing host or a missing proxy?

I have a script that requests a given URL via a proxy. A failure to connect to the proxy gives an identical error to a failure to connect to the URL over a successful proxy connection.

This code:

var opts = url.parse("https://192.168.0.10/");//this ip address doesn't resolve anywhere
opts.agent = new SocksProxyAgent("socks4://works.local:1080");//this proxy works
    
https.get(opts, function (resp) {

    //successful request is dealt with

}).on("error", function (err) {console.log(err)});

Produces this output:

SocksClientError: Proxy connection timed out
#I cutout the stack trace for brevity
  options: {
    proxy: { host: 'works.local', port: 1080, type: 4 },
    destination: { host: '192.168.0.10', port: 443 },
    command: 'connect',
    timeout: undefined
  }

If I run the same code but instead with a working URL, and a deliberately non-resolving proxy, I get an identical error message.

Is there a convenient way of being more specific about what is broken, whether a failure to connect to the proxy, or a failure to connect to the target URL?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda