• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

132
Vistas
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?

almost 3 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda