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,
|
||||
ServiceEndpoints,
|
||||
} from '@nodecfdi/sat-ws-descarga-masiva';
|
||||
import { proxyManager } from './proxy.service.js';
|
||||
|
||||
export interface FielData {
|
||||
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
|
||||
// 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)(
|
||||
undefined,
|
||||
undefined,
|
||||
SAT_WEB_CLIENT_TIMEOUT_MS,
|
||||
proxyAgent,
|
||||
);
|
||||
|
||||
// Crear request builder con la FIEL
|
||||
|
||||
Reference in New Issue
Block a user