PJCHENder 未整理筆記

[Node] NodeJS Tips 小技巧筆記

2017-10-03

@(NodeJS)[tips]

[Node] NodeJS 小技巧(NodeJS Tips)

常見問題

Error: ECONNRESET

嘗試設定 maxSocket 的數量,預設是無上限:

1
2
3
4
5
6
7
var http = require('http') // Do the same with the 'https' module if you do https requests
var httpAgent = new http.Agent()
httpAgent.maxSockets = 15

let options = {
pool: httpAgent
}

如果是透過 requestJS 可以嘗試設定 pool: {maxSockets: 15}timeout

1
2
3
4
5
6
7
let options = {
url: 'http://foo.bar',
timeout: 30000,
pool: { maxSockets: 15 },
}

request(options, (err, res, body) => {})

How to set max concurrent connections and a queue? @ requestJS Github Issues
http @ NodeJS Doc

Error: ESOCKETTIMEDOUT

掃描二維條碼,分享此文章