feat(sat): integra ProxyManager en createSatService
- Usa proxyManager.createNextAgent() para obtener un proxy del pool. - Pasa el agente al HttpsWebClient parcheado. - Log indica si se usa proxy o IP directa. - Comportamiento actual sin cambios si SAT_PROXY_LIST está vacío.
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
DocumentStatus,
|
DocumentStatus,
|
||||||
ServiceEndpoints,
|
ServiceEndpoints,
|
||||||
} from '@nodecfdi/sat-ws-descarga-masiva';
|
} from '@nodecfdi/sat-ws-descarga-masiva';
|
||||||
|
import { proxyManager } from './proxy.service.js';
|
||||||
|
|
||||||
export interface FielData {
|
export interface FielData {
|
||||||
cerContent: string;
|
cerContent: string;
|
||||||
@@ -47,11 +48,20 @@ export function createSatService(fielData: FielData): Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crear cliente HTTP con timeout explícito para evitar el bug de la librería
|
// Crear cliente HTTP con timeout explícito para evitar el bug de la librería
|
||||||
// cuando ocurre un timeout de red.
|
// cuando ocurre un timeout de red. Si hay proxies configurados, se usa uno
|
||||||
|
// del pool para reducir el riesgo de bloqueo por IP del SAT.
|
||||||
|
const proxyAgent = proxyManager.createNextAgent();
|
||||||
|
if (proxyAgent) {
|
||||||
|
console.log('[SAT] Usando proxy para la conexión con el SAT');
|
||||||
|
} else {
|
||||||
|
console.log('[SAT] Sin proxy configurado; usando IP directa del servidor');
|
||||||
|
}
|
||||||
|
|
||||||
const webClient = new (HttpsWebClient as any)(
|
const webClient = new (HttpsWebClient as any)(
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
SAT_WEB_CLIENT_TIMEOUT_MS,
|
SAT_WEB_CLIENT_TIMEOUT_MS,
|
||||||
|
proxyAgent,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Crear request builder con la FIEL
|
// Crear request builder con la FIEL
|
||||||
|
|||||||
Reference in New Issue
Block a user