我正在尝试设置请求的maxSockets,并在创建客户端时将其发送到node-soap。事务在没有这个的情况下运行得很好。我尝试通过httpAgent添加它,但是一旦添加了maxSockets属性,我就得到了一个socket hang up错误。因此,我现在的方法是尝试使用库中提供的httpClient对其进行配置,但是,我还无法做到这一点。下面是我的代码:
//OPTION 1
const httpsAgent = new https.Agent({ keepAlive: true });
const httpsClient: AxiosInstance = axios.create();
httpsClient.request({
url: url,
httpsAgent: httpsAgent,
timeout: 15000,
});
//OPTION 2
const httpsAgent = new https.Agent({ keepAlive: true });
const httpsClient: AxiosInstance = axios.create();
httpsClient.defaults.httpsAgent = HttpsAgent;这就是这个库的文档对httpClient的描述:httpClient: to provide your own http client that implements request(url, data, callback, exheaders, exoptions).
发布于 2020-05-04 05:18:56
已发现在HTTP Agent上设置keepAlive属性会终止连接。因此,在创建客户端时,我只在其上设置了maxSockets,并向node-soap添加了一个头。
client.addHttpHeader("connection", "keep-alive");
https://stackoverflow.com/questions/61493554
复制相似问题