简体   繁体   中英

Provide httpClient to node-soap

I am trying to set the maxSockets on the request and send this to node-soap when creating the client. The transactions work well without this. I tried adding it through the httpAgent but once the maxSockets property is added I got a socket hang up error. So, my approach now is to try to configure this using the httpClient available on the library, however, I haven't been able to do it. Here is my code:

//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;

This is what the library's documentation says about the httpClient: httpClient: to provide your own http client that implements request(url, data, callback, exheaders, exoptions).

Found out that setting the keepAlive property on the HTTP Agent was killing the connection. So I set it up only the maxSockets on it and add a header to node-soap when creating the client.

client.addHttpHeader("connection", "keep-alive");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM