diff --git a/rest/controllers/servidor_controller.go b/rest/controllers/servidor_controller.go index 3e55cd9..551419f 100755 --- a/rest/controllers/servidor_controller.go +++ b/rest/controllers/servidor_controller.go @@ -252,7 +252,7 @@ func PingConexion(c *fiber.Ctx) error { // Intentar conexión TCP addr := fmt.Sprintf("%s:%s", conexion.Servidor.IpServidor, conexion.Puerto) - conn, err := net.DialTimeout("tcp", addr, 5*time.Second) + conn, err := net.DialTimeout("tcp", addr, 2*time.Second) if err == nil { conn.Close() exitoso = true @@ -269,11 +269,17 @@ func PingConexion(c *fiber.Ctx) error { } } + errorMsg := "" + if !exitoso { + errorMsg = fmt.Sprintf("No se pudo conectar a %s:%s", conexion.Servidor.IpServidor, conexion.Puerto) + } + return c.JSON(fiber.Map{ "exitoso": exitoso, "tiempo": tiempoMs, "host": conexion.Servidor.IpServidor, "puerto": conexion.Puerto, "tipo": conexion.TipoDb.Nombre, + "error": errorMsg, }) }