Histórico de mensagens sobre ECONNRESET em devs

EXIBINDO CONVERSAS RECENTES:

Texto: ECONNRESET
Canal: devs
Avatar discord do usuario jonadabir

jonadabir

Ver Respostas

estou tentando fazer a req de obter autorização PIX porem estou recebendo o seguinte erro:

ts
cause: Error: socket hang up
at TLSSocket.socketOnEnd (node:_http_client:524:23)
at TLSSocket.emit (node:events:531:35)
at endReadableNT (node:internal/streams/readable:1696:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ECONNRESET'
}
Meu código:
ts
const certificatePath = path.join(
__dirname,
'../../../certificates/pix_certificate.p12',
);

const certificate = fs.readFileSync(certificatePath);

const getPixAuthorization = async () => {
const agent = new https.Agent({
pfx: certificate,
passphrase: '',
});

const authParams = {
method: 'POST',
url: 'https://pix-h.api.efipay.com.br/oauth/token',
auth: {
username: credentials.client_id,
password: credentials.client_secret,
},
data: {
grant_type: 'client_credentials',
},
httpsAgent: agent,
};

const authRes = await axios(authParams);

return authRes.data;
};